We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 70cc57c commit 4627729Copy full SHA for 4627729
stdlib/Distributed/src/macros.jl
@@ -1,14 +1,10 @@
1
# This file is a part of Julia. License is MIT: https://julialang.org/license
2
3
-let nextidx = 0
+let nextidx = Threads.Atomic{Int}(0)
4
global nextproc
5
function nextproc()
6
- p = -1
7
- if p == -1
8
- p = workers()[(nextidx % nworkers()) + 1]
9
- nextidx += 1
10
- end
11
- p
+ idx = Threads.atomic_add!(nextidx, 1)
+ return workers()[(idx % nworkers()) + 1]
12
end
13
14
0 commit comments