Skip to content

Commit

Permalink
MT: start spinning immediately in #find_next_runnable
Browse files Browse the repository at this point in the history
Same reasoning as for ST.
  • Loading branch information
ysbaddaden committed Sep 27, 2024
1 parent c9716a6 commit 9203290
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 18 deletions.
12 changes: 2 additions & 10 deletions src/multi_threaded/scheduler.cr
Original file line number Diff line number Diff line change
Expand Up @@ -142,23 +142,15 @@ module ExecutionContext
end

private def find_next_runnable(&) : Nil
# try queues & the event loop
yield @runnables.get?
yield @global_queue.grab?(@runnables, divisor: @execution_context.size)

if @execution_context.lock_evloop? { @event_loop.run(blocking: false) }
yield @runnables.get?
end

# nothing to do: start spinning
spinning do
yield try_steal?

if @execution_context.lock_evloop? { @event_loop.run(blocking: false) }
yield @runnables.get?
end

yield @global_queue.grab?(@runnables, divisor: @execution_context.size)

yield try_steal?
end

# wait on the event loop for events and timers to activate
Expand Down
8 changes: 0 additions & 8 deletions src/single_threaded.cr
Original file line number Diff line number Diff line change
Expand Up @@ -190,14 +190,6 @@ module ExecutionContext
end

private def find_next_runnable(&) : Nil
# try queues & the event loop
# yield @runnables.get?
# yield @global_queue.grab?(@runnables, divisor: 1)

# if @event_loop.run(blocking: false)
# yield @runnables.get?
# end

# nothing to do: start spinning
spinning do
yield @global_queue.grab?(@runnables, divisor: 1)
Expand Down

0 comments on commit 9203290

Please sign in to comment.