tangled
alpha
login
or
join now
rockorager.dev
/
comlink
2
fork
atom
an experimental irc client
2
fork
atom
overview
issues
pulls
pipelines
atomic: use acquire and release semantics
rockorager.dev
1 year ago
87060414
47b883bd
verified
This commit was signed with the committer's
known signature
.
rockorager.dev
SSH Key Fingerprint:
SHA256:qn/Fjy7CpbcogGEPB14Y53hLnQleZNFY9lkQnuudFLs=
+6
-6
1 changed file
expand all
collapse all
unified
split
src
irc.zig
+6
-6
src/irc.zig
···
1824
1824
1825
1825
/// Closes the connection
1826
1826
pub fn close(self: *Client) void {
1827
1827
-
if (self.status.load(.unordered) == .disconnected) return;
1827
1827
+
if (self.status.load(.acquire) == .disconnected) return;
1828
1828
if (self.config.tls) {
1829
1829
self.client.close() catch {};
1830
1830
}
···
1884
1884
const self: *Client = @ptrCast(@alignCast(ptr));
1885
1885
switch (event) {
1886
1886
.tick => {
1887
1887
-
const status = self.status.load(.unordered);
1887
1887
+
const status = self.status.load(.acquire);
1888
1888
switch (status) {
1889
1889
.disconnected => {
1890
1890
// Clean up a thread if we have one
···
1892
1892
thread.join();
1893
1893
self.thread = null;
1894
1894
}
1895
1895
-
self.status.store(.connecting, .unordered);
1895
1895
+
self.status.store(.connecting, .release);
1896
1896
self.thread = try std.Thread.spawn(.{}, Client.readThread, .{self});
1897
1897
},
1898
1898
.connecting => {},
···
2015
2015
var style: vaxis.Style = .{};
2016
2016
if (selected) style.reverse = true;
2017
2017
if (self.has_mouse) style.bg = .{ .index = 8 };
2018
2018
-
if (self.status.load(.unordered) == .disconnected) style.fg = .{ .index = 8 };
2018
2018
+
if (self.status.load(.acquire) == .disconnected) style.fg = .{ .index = 8 };
2019
2019
2020
2020
const name = self.config.name orelse self.config.server;
2021
2021
···
2793
2793
2794
2794
pub fn write(self: *Client, buf: []const u8) !void {
2795
2795
assert(std.mem.endsWith(u8, buf, "\r\n"));
2796
2796
-
if (self.status.load(.unordered) == .disconnected) {
2796
2796
+
if (self.status.load(.acquire) == .disconnected) {
2797
2797
log.warn("disconnected: dropping write: {s}", .{buf[0 .. buf.len - 2]});
2798
2798
return;
2799
2799
}
···
2816
2816
const port: u16 = self.config.port orelse 6667;
2817
2817
self.stream = try std.net.tcpConnectToHost(self.alloc, self.config.server, port);
2818
2818
}
2819
2819
-
self.status.store(.connected, .unordered);
2819
2819
+
self.status.store(.connected, .release);
2820
2820
2821
2821
try self.configureKeepalive(keepalive_idle);
2822
2822
}