Skip to content

Commit 2c418d6

Browse files
committed
loop: inline cancelAll and remove useless resetEvents
1 parent 88d29c9 commit 2c418d6

File tree

1 file changed

+1
-21
lines changed

1 file changed

+1
-21
lines changed

src/loop.zig

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ pub const SingleThreaded = struct {
9292
};
9393
}
9494
if (comptime CANCEL_SUPPORTED) {
95-
self.cancelAll();
95+
self.io.cancel_all();
9696
}
9797
self.io.deinit();
9898
self.cancel_pool.deinit();
@@ -142,9 +142,6 @@ pub const SingleThreaded = struct {
142142
fn eventsNb(self: *Self, comptime event: Event) usize {
143143
return @atomicLoad(usize, self.eventsPtr(event), .seq_cst);
144144
}
145-
fn resetEvents(self: *Self, comptime event: Event) void {
146-
@atomicStore(usize, self.eventsPtr(event), 0, .unordered);
147-
}
148145

149146
// JS callbacks APIs
150147
// -----------------
@@ -288,36 +285,19 @@ pub const SingleThreaded = struct {
288285
self.io.cancel_one(*ContextCancel, ctx, cancelCallback, completion, comp_cancel);
289286
}
290287

291-
// cancelAll will cancel all future events.
292-
// The loop will not be usable anymore after cancelAll.
293-
// It is used only during the deinit.
294-
fn cancelAll(self: *Self) void {
295-
self.resetEvents(.js);
296-
self.resetEvents(.zig);
297-
self.io.cancel_all();
298-
}
299-
300288
// Reset all existing JS callbacks.
301289
// The existing events will happen and their memory will be cleanup but the
302290
// corresponding callbacks will not be called.
303291
pub fn resetJS(self: *Self) void {
304292
self.js_ctx_id += 1;
305293
self.cancelled.clearRetainingCapacity();
306-
// We don't call self.resetEvents(.js) intentionnaly.
307-
// Indeed we don't want to prevent the possibility to wait for events.
308-
// The caller may want to wait to have memory correcly cleaned after
309-
// the events happen, even if the callback are ignoreed.
310294
}
311295

312296
// Reset all existing Zig callbacks.
313297
// The existing events will happen and their memory will be cleanup but the
314298
// corresponding callbacks will not be called.
315299
pub fn resetZig(self: *Self) void {
316300
self.zig_ctx_id += 1;
317-
// We don't call self.resetEvents(.zig) intentionnaly.
318-
// Indeed we don't want to prevent the possibility to wait for events.
319-
// The caller may want to wait to have memory correcly cleaned after
320-
// the events happen, even if the callback are ignoreed.
321301
}
322302

323303
// IO callbacks APIs

0 commit comments

Comments
 (0)