Skip to content

Commit 8ef6ca2

Browse files
committed
remove completion pool to fix linux build dependency loop
1 parent c29255e commit 8ef6ca2

File tree

1 file changed

+10
-16
lines changed

1 file changed

+10
-16
lines changed

src/loop.zig

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ pub const SingleThreaded = struct {
5151

5252
cancel_pool: MemoryPool(ContextCancel),
5353
timeout_pool: MemoryPool(ContextTimeout),
54-
completion_pool: MemoryPool(Completion),
5554
event_callback_pool: MemoryPool(EventCallbackContext),
5655

5756
const Self = @This();
@@ -69,7 +68,6 @@ pub const SingleThreaded = struct {
6968
.zig_events_nb = 0,
7069
.cancel_pool = MemoryPool(ContextCancel).init(alloc),
7170
.timeout_pool = MemoryPool(ContextTimeout).init(alloc),
72-
.completion_pool = MemoryPool(Completion).init(alloc),
7371
.event_callback_pool = MemoryPool(EventCallbackContext).init(alloc),
7472
};
7573
}
@@ -87,7 +85,6 @@ pub const SingleThreaded = struct {
8785
self.io.deinit();
8886
self.cancel_pool.deinit();
8987
self.timeout_pool.deinit();
90-
self.completion_pool.deinit();
9188
self.event_callback_pool.deinit();
9289
}
9390

@@ -156,7 +153,7 @@ pub const SingleThreaded = struct {
156153
defer {
157154
loop.removeEvent(.js);
158155
loop.timeout_pool.destroy(ctx);
159-
loop.completion_pool.destroy(completion);
156+
loop.alloc.destroy(completion);
160157
}
161158

162159
// If the loop's context id has changed, don't call the js callback
@@ -183,8 +180,8 @@ pub const SingleThreaded = struct {
183180
}
184181

185182
pub fn timeout(self: *Self, nanoseconds: u63, js_cbk: ?JSCallback) !usize {
186-
const completion = try self.completion_pool.create();
187-
errdefer self.completion_pool.destroy(completion);
183+
const completion = try self.alloc.create(Completion);
184+
errdefer self.alloc.destroy(completion);
188185
completion.* = undefined;
189186

190187
const ctx = try self.timeout_pool.create();
@@ -215,8 +212,8 @@ pub const SingleThreaded = struct {
215212

216213
defer {
217214
loop.removeEvent(.js);
218-
loop.timeout_pool.destroy(ctx);
219-
loop.completion_pool.destroy(completion);
215+
loop.cancel_pool.destroy(ctx);
216+
loop.alloc.destroy(completion);
220217
}
221218

222219
// If the loop's context id has changed, don't call the js callback
@@ -245,8 +242,8 @@ pub const SingleThreaded = struct {
245242
pub fn cancel(self: *Self, id: usize, js_cbk: ?JSCallback) !void {
246243
const comp_cancel: *IO.Completion = @ptrFromInt(id);
247244

248-
const completion = try self.completion_pool.create();
249-
errdefer self.completion_pool.destroy(completion);
245+
const completion = try self.alloc.create(Completion);
246+
errdefer self.alloc.destroy(completion);
250247
completion.* = undefined;
251248

252249
const ctx = self.alloc.create(ContextCancel) catch unreachable;
@@ -360,7 +357,6 @@ pub const SingleThreaded = struct {
360357
self.io.recv(*EventCallbackContext, callback, onRecv, completion, socket, buf);
361358
}
362359

363-
364360
// Zig timeout
365361

366362
const ContextZigTimeout = struct {
@@ -382,7 +378,7 @@ pub const SingleThreaded = struct {
382378
defer {
383379
loop.removeEvent(.zig);
384380
loop.alloc.destroy(ctx);
385-
loop.completion_pool.destroy(completion);
381+
loop.alloc.destroy(completion);
386382
}
387383

388384
// If the loop's context id has changed, don't call the js callback
@@ -410,11 +406,9 @@ pub const SingleThreaded = struct {
410406
context: Context,
411407
comptime callback: fn (context: Context) void,
412408
) void {
413-
const completion = self.completion_pool.create() catch unreachable;
414-
errdefer self.completion_pool.destroy(completion);
409+
const completion = self.alloc.create(IO.Completion) catch unreachable;
415410
completion.* = undefined;
416-
417-
const ctxtimeout = self.alloc.create(ContextZigTimeout) catch unreachable;
411+
const ctxtimeout = self.alloc.create(ContextZigTimeout) catch unreachable;
418412
ctxtimeout.* = ContextZigTimeout{
419413
.loop = self,
420414
.zig_ctx_id = self.zig_ctx_id,

0 commit comments

Comments
 (0)