| ... | ... | @@ -494,13 +494,12 @@ fn async( |
| 494 | 494 | const DetachedClosure = struct { |
| 495 | 495 | pool: *Pool, |
| 496 | 496 | func: *const fn (context: *anyopaque) void, |
| 497 | | run_node: Pool.RunQueue.Node = .{ .data = .{ .runFn = runFn } }, |
| 497 | runnable: Runnable = .{ .runFn = runFn }, |
| 498 | 498 | context_alignment: std.mem.Alignment, |
| 499 | 499 | context_len: usize, |
| 500 | 500 | |
| 501 | 501 | fn runFn(runnable: *Pool.Runnable, _: ?usize) void { |
| 502 | | const run_node: *Pool.RunQueue.Node = @fieldParentPtr("data", runnable); |
| 503 | | const closure: *DetachedClosure = @alignCast(@fieldParentPtr("run_node", run_node)); |
| 502 | const closure: *DetachedClosure = @alignCast(@fieldParentPtr("runnable", runnable)); |
| 504 | 503 | closure.func(closure.contextPointer()); |
| 505 | 504 | const gpa = closure.pool.allocator; |
| 506 | 505 | const base: [*]align(@alignOf(DetachedClosure)) u8 = @ptrCast(closure); |
| ... | ... | @@ -544,7 +543,7 @@ fn asyncDetached( |
| 544 | 543 | .context_len = context.len, |
| 545 | 544 | }; |
| 546 | 545 | @memcpy(closure.contextPointer()[0..context.len], context); |
| 547 | | pool.run_queue.prepend(&closure.run_node); |
| 546 | pool.run_queue.prepend(&closure.runnable.node); |
| 548 | 547 | |
| 549 | 548 | if (pool.threads.items.len < pool.threads.capacity) { |
| 550 | 549 | pool.threads.addOneAssumeCapacity().* = std.Thread.spawn(.{ |