File tree Expand file tree Collapse file tree 1 file changed +2
-23
lines changed Expand file tree Collapse file tree 1 file changed +2
-23
lines changed Original file line number Diff line number Diff line change @@ -909,31 +909,10 @@ function list_deletefirst!(W::IntrusiveLinkedListSynchronized{T}, t::T) where T
909
909
end
910
910
911
911
const StickyWorkqueue = IntrusiveLinkedListSynchronized{Task}
912
- global Workqueues:: Vector{StickyWorkqueue} = [StickyWorkqueue ()]
913
- const Workqueues_lock = Threads. SpinLock ()
912
+ const Workqueues = OncePerThread {StickyWorkqueue} (StickyWorkqueue)
914
913
const Workqueue = Workqueues[1 ] # default work queue is thread 1 // TODO : deprecate this variable
915
914
916
- function workqueue_for (tid:: Int )
917
- qs = Workqueues
918
- if length (qs) >= tid && isassigned (qs, tid)
919
- return @inbounds qs[tid]
920
- end
921
- # slow path to allocate it
922
- @assert tid > 0
923
- l = Workqueues_lock
924
- @lock l begin
925
- qs = Workqueues
926
- if length (qs) < tid
927
- nt = Threads. maxthreadid ()
928
- @assert tid <= nt
929
- global Workqueues = qs = copyto! (typeof (qs)(undef, length (qs) + nt - 1 ), qs)
930
- end
931
- if ! isassigned (qs, tid)
932
- @inbounds qs[tid] = StickyWorkqueue ()
933
- end
934
- return @inbounds qs[tid]
935
- end
936
- end
915
+ workqueue_for (tid:: Int ) = Workqueues[tid]
937
916
938
917
function enq_work (t:: Task )
939
918
(t. _state === task_state_runnable && t. queue === nothing ) || error (" schedule: Task not runnable" )
You can’t perform that action at this time.
0 commit comments