Skip to content

Commit

Permalink
chore(kqueue): standardize change_count check
Browse files Browse the repository at this point in the history
  • Loading branch information
mookums committed Dec 13, 2024
1 parent 9d0b398 commit f1e70ed
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/aio/apis/kqueue.zig
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@ pub const AsyncKQueue = struct {
};

const event = &kqueue.changes[kqueue.change_count];
defer kqueue.change_count += 1;
assert(kqueue.change_count < kqueue.changes.len);
kqueue.change_count += 1;
event.* = std.posix.Kevent{
.ident = @intCast(fd),
.filter = std.posix.system.EVFILT_READ,
Expand Down Expand Up @@ -213,7 +214,8 @@ pub const AsyncKQueue = struct {
};

const event = &kqueue.changes[kqueue.change_count];
defer kqueue.change_count += 1;
assert(kqueue.change_count < kqueue.changes.len);
kqueue.change_count += 1;
event.* = .{
.ident = @intCast(fd),
.filter = std.posix.system.EVFILT_WRITE,
Expand Down Expand Up @@ -289,7 +291,8 @@ pub const AsyncKQueue = struct {
};

const event = &kqueue.changes[kqueue.change_count];
defer kqueue.change_count += 1;
assert(kqueue.change_count < kqueue.changes.len);
kqueue.change_count += 1;
event.* = .{
.ident = @intCast(socket),
.filter = std.posix.system.EVFILT_WRITE,
Expand Down Expand Up @@ -354,7 +357,6 @@ pub const AsyncKQueue = struct {
const event = &kqueue.changes[kqueue.change_count];
assert(kqueue.change_count < kqueue.changes.len);
kqueue.change_count += 1;

event.* = .{
.ident = @intCast(socket),
.filter = std.posix.system.EVFILT_WRITE,
Expand Down Expand Up @@ -537,10 +539,12 @@ pub const AsyncKQueue = struct {
else => unreachable,
.wake => {
assert(event.filter == std.posix.system.EVFILT_USER);
assert(event.ident == WAKE_IDENT);
job_complete = false;
break :blk .wake;
},
.timer => |inner| {
assert(event.filter == std.posix.system.EVFILT_TIMER);
assert(inner == .none);
break :blk .none;
},
Expand Down

0 comments on commit f1e70ed

Please sign in to comment.