Skip to content

Commit

Permalink
Fix: MT may fail to wake other schedulers after evloop run
Browse files Browse the repository at this point in the history
  • Loading branch information
ysbaddaden committed Feb 11, 2025
1 parent d5bb3bc commit 21aba17
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/fiber/execution_context/multi_threaded/scheduler.cr
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,13 @@ module Fiber::ExecutionContext
yield @global_queue.grab?(@runnables, divisor: @execution_context.size)

if @execution_context.lock_evloop? { @event_loop.run(pointerof(list), blocking: false) }
if fiber = enqueue_many(pointerof(list))
unless list.empty?
# must stop spinning before calling enqueue_many that may call
# wake_scheduler which returns immediately if a thread is
# spinning... but we're spinning, so that would always fail to
# wake sleeping schedulers despite having runnable fibers
spin_stop
yield fiber
yield enqueue_many(pointerof(list))
end
end

Expand Down

0 comments on commit 21aba17

Please sign in to comment.