@@ -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 ;
@@ -382,7 +379,7 @@ pub const SingleThreaded = struct {
382379 defer {
383380 loop .removeEvent (.zig );
384381 loop .alloc .destroy (ctx );
385- loop .completion_pool .destroy (completion );
382+ loop .alloc .destroy (completion );
386383 }
387384
388385 // If the loop's context id has changed, don't call the js callback
@@ -410,10 +407,8 @@ pub const SingleThreaded = struct {
410407 context : Context ,
411408 comptime callback : fn (context : Context ) void ,
412409 ) void {
413- const completion = self .completion_pool .create () catch unreachable ;
414- errdefer self .completion_pool .destroy (completion );
410+ const completion = self .alloc .create (IO .Completion ) catch unreachable ;
415411 completion .* = undefined ;
416-
417412 const ctxtimeout = self .alloc .create (ContextZigTimeout ) catch unreachable ;
418413 ctxtimeout .* = ContextZigTimeout {
419414 .loop = self ,
0 commit comments