Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 5 additions & 16 deletions base/task.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1201,30 +1201,19 @@ function wait()
process_events()

# get the next task to run
result = nothing
have_result = false
W = workqueue_for(Threads.threadid())
task = trypoptask(W)
if !(task isa Task)
if task === nothing
# No tasks to run; switch to the scheduler task to run the
# thread sleep logic.
sched_task = get_sched_task()
if ct !== sched_task
result = yieldto(sched_task)
have_result = true
else
task = ccall(:jl_task_get_next, Ref{Task}, (Any, Any, Any),
trypoptask, W, checktaskempty)
return yieldto(sched_task)
end
task = ccall(:jl_task_get_next, Ref{Task}, (Any, Any, Any), trypoptask, W, checktaskempty)
end
# We may have already switched tasks (via the scheduler task), so
# only switch if we haven't.
if !have_result
@assert task isa Task
set_next_task(task)
result = try_yieldto(ensure_rescheduled)
end
return result
set_next_task(task)
return try_yieldto(ensure_rescheduled)
end

if Sys.iswindows()
Expand Down