@@ -151,7 +151,7 @@ function set_worker_state(w, state)
151
151
end
152
152
153
153
function check_worker_state (w:: Worker )
154
- if w. state === W_CREATED
154
+ if ( @atomic w. state) === W_CREATED
155
155
if ! isclusterlazy ()
156
156
if PGRP. topology === :all_to_all
157
157
# Since higher pids connect with lower pids, the remote worker
@@ -190,7 +190,7 @@ function exec_conn_func(w::Worker)
190
190
end
191
191
192
192
function wait_for_conn (w)
193
- if w. state === W_CREATED
193
+ if ( @atomic w. state) === W_CREATED
194
194
timeout = worker_timeout () - (time () - w. ct_time)
195
195
timeout <= 0 && error (" peer $(w. id) has not connected to $(myid ()) " )
196
196
@@ -203,7 +203,7 @@ function wait_for_conn(w)
203
203
errormonitor (T)
204
204
lock (w. c_state) do
205
205
wait (w. c_state)
206
- w. state === W_CREATED && error (" peer $(w. id) didn't connect to $(myid ()) within $timeout seconds" )
206
+ ( @atomic w. state) === W_CREATED && error (" peer $(w. id) didn't connect to $(myid ()) within $timeout seconds" )
207
207
end
208
208
end
209
209
nothing
@@ -661,7 +661,7 @@ function create_worker(manager, wconfig)
661
661
if (jw. id != 1 ) && (jw. id < w. id)
662
662
lock (jw. c_state) do
663
663
# wait for wl to join
664
- if jw. state === W_CREATED
664
+ if ( @atomic jw. state) === W_CREATED
665
665
wait (jw. c_state)
666
666
end
667
667
end
@@ -688,7 +688,7 @@ function create_worker(manager, wconfig)
688
688
689
689
for wl in wlist
690
690
lock (wl. c_state) do
691
- if wl. state === W_CREATED
691
+ if ( @atomic wl. state) === W_CREATED
692
692
# wait for wl to join
693
693
wait (wl. c_state)
694
694
end
@@ -903,7 +903,7 @@ function nprocs()
903
903
n = length (PGRP. workers)
904
904
# filter out workers in the process of being setup/shutdown.
905
905
for jw in PGRP. workers
906
- if ! isa (jw, LocalProcess) && (jw. state != = W_CONNECTED)
906
+ if ! isa (jw, LocalProcess) && (( @atomic jw. state) != = W_CONNECTED)
907
907
n = n - 1
908
908
end
909
909
end
@@ -954,7 +954,7 @@ julia> procs()
954
954
function procs ()
955
955
if myid () == 1 || (PGRP. topology === :all_to_all && ! isclusterlazy ())
956
956
# filter out workers in the process of being setup/shutdown.
957
- return Int[x. id for x in PGRP. workers if isa (x, LocalProcess) || (x. state === W_CONNECTED)]
957
+ return Int[x. id for x in PGRP. workers if isa (x, LocalProcess) || (( @atomic x. state) === W_CONNECTED)]
958
958
else
959
959
return Int[x. id for x in PGRP. workers]
960
960
end
963
963
function id_in_procs (id) # faster version of `id in procs()`
964
964
if myid () == 1 || (PGRP. topology === :all_to_all && ! isclusterlazy ())
965
965
for x in PGRP. workers
966
- if (x. id:: Int ) == id && (isa (x, LocalProcess) || (x:: Worker ). state === W_CONNECTED)
966
+ if (x. id:: Int ) == id && (isa (x, LocalProcess) || (@atomic ( x:: Worker ). state) === W_CONNECTED)
967
967
return true
968
968
end
969
969
end
@@ -985,7 +985,7 @@ Specifically all workers bound to the same ip-address as `pid` are returned.
985
985
"""
986
986
function procs (pid:: Integer )
987
987
if myid () == 1
988
- all_workers = [x for x in PGRP. workers if isa (x, LocalProcess) || (x. state === W_CONNECTED)]
988
+ all_workers = [x for x in PGRP. workers if isa (x, LocalProcess) || (( @atomic x. state) === W_CONNECTED)]
989
989
if (pid == 1 ) || (isa (map_pid_wrkr[pid]. manager, LocalManager))
990
990
Int[x. id for x in filter (w -> (w. id== 1 ) || (isa (w. manager, LocalManager)), all_workers)]
991
991
else
@@ -1092,11 +1092,11 @@ function _rmprocs(pids, waitfor)
1092
1092
1093
1093
start = time_ns ()
1094
1094
while (time_ns () - start) < waitfor* 1e9
1095
- all (w -> w. state === W_TERMINATED, rmprocset) && break
1095
+ all (w -> ( @atomic w. state) === W_TERMINATED, rmprocset) && break
1096
1096
sleep (min (0.1 , waitfor - (time_ns () - start)/ 1e9 ))
1097
1097
end
1098
1098
1099
- unremoved = [wrkr. id for wrkr in filter (w -> w. state != = W_TERMINATED, rmprocset)]
1099
+ unremoved = [wrkr. id for wrkr in filter (w -> ( @atomic w. state) != = W_TERMINATED, rmprocset)]
1100
1100
if length (unremoved) > 0
1101
1101
estr = string (" rmprocs: pids " , unremoved, " not terminated after " , waitfor, " seconds." )
1102
1102
throw (ErrorException (estr))
0 commit comments