aboutsummaryrefslogtreecommitdiff
path: root/lib/std
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2025-03-31 17:06:05 -0700
committerAndrew Kelley <andrew@ziglang.org>2025-10-29 06:20:48 -0700
commit4063205746efec752faaece85355c01de55ef08e (patch)
treed944cb50c242b50f44b2b8929eb95545bfd14325 /lib/std
parent929b616e0f9cb00bfba9901a83c9b4b2203ed094 (diff)
downloadzig-4063205746efec752faaece85355c01de55ef08e.tar.gz
zig-4063205746efec752faaece85355c01de55ef08e.zip
EventLoop: remove broken mechanism for making deinit block on detached
Diffstat (limited to 'lib/std')
-rw-r--r--lib/std/Io/EventLoop.zig17
1 files changed, 1 insertions, 16 deletions
diff --git a/lib/std/Io/EventLoop.zig b/lib/std/Io/EventLoop.zig
index a27e197b7d..e5ab70dfd0 100644
--- a/lib/std/Io/EventLoop.zig
+++ b/lib/std/Io/EventLoop.zig
@@ -27,7 +27,6 @@ const Thread = struct {
current_context: *Context,
ready_queue: ?*Fiber,
free_queue: ?*Fiber,
- detached_queue: ?*Fiber,
io_uring: IoUring,
idle_search_index: u32,
steal_ready_search_index: u32,
@@ -209,7 +208,6 @@ pub fn init(el: *EventLoop, gpa: Allocator) !void {
.current_context = &main_fiber.context,
.ready_queue = null,
.free_queue = null,
- .detached_queue = null,
.io_uring = try IoUring.init(io_uring_entries, 0),
.idle_search_index = 1,
.steal_ready_search_index = 1,
@@ -220,17 +218,8 @@ pub fn init(el: *EventLoop, gpa: Allocator) !void {
}
pub fn deinit(el: *EventLoop) void {
- // Wait for detached fibers.
const active_threads = @atomicLoad(u32, &el.threads.active, .acquire);
for (el.threads.allocated[0..active_threads]) |*thread| {
- while (thread.detached_queue) |detached_fiber| {
- if (@atomicLoad(?*Fiber, &detached_fiber.awaiter, .acquire) != Fiber.finished)
- el.yield(null, .{ .register_awaiter = &detached_fiber.awaiter });
- detached_fiber.recycle();
- }
- }
-
- for (el.threads.allocated[0..active_threads]) |*thread| {
const ready_fiber = @atomicLoad(?*Fiber, &thread.ready_queue, .monotonic);
assert(ready_fiber == null or ready_fiber == Fiber.finished); // pending async
}
@@ -347,7 +336,6 @@ fn schedule(el: *EventLoop, thread: *Thread, ready_queue: Fiber.Queue) void {
.current_context = &new_thread.idle_context,
.ready_queue = ready_queue.head,
.free_queue = null,
- .detached_queue = null,
.io_uring = IoUring.init(io_uring_entries, 0) catch |err| {
@atomicStore(u32, &el.threads.reserved, new_thread_index, .release);
// no more access to `thread` after giving up reservation
@@ -673,8 +661,6 @@ const DetachedClosure = struct {
message.handle(closure.event_loop);
std.log.debug("{*} performing async detached", .{closure.fiber});
closure.start(closure.contextPointer());
- const current_thread: *Thread = .current();
- current_thread.detached_queue = closure.fiber.queue_next;
const awaiter = @atomicRmw(?*Fiber, &closure.fiber.awaiter, .Xchg, Fiber.finished, .acq_rel);
if (awaiter) |a| {
closure.event_loop.yield(a, .nothing);
@@ -766,11 +752,10 @@ fn go(
else => |arch| @compileError("unimplemented architecture: " ++ @tagName(arch)),
},
.awaiter = null,
- .queue_next = current_thread.detached_queue,
+ .queue_next = null,
.cancel_thread = null,
.awaiting_completions = .initEmpty(),
};
- current_thread.detached_queue = fiber;
closure.* = .{
.event_loop = event_loop,
.fiber = fiber,