Skip to content

Commit 5647ff7

Browse files
committed
Make Worker.c_state threadsafe
1 parent 3b11b1f commit 5647ff7

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

stdlib/Distributed/src/cluster.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ mutable struct Worker
9999
add_msgs::Array{Any,1}
100100
gcflag::Bool
101101
state::WorkerState
102-
c_state::Condition # wait for state changes
102+
c_state::Event # wait for state changes
103103
ct_time::Float64 # creation time
104104
conn_func::Any # used to setup connections lazily
105105

@@ -133,7 +133,7 @@ mutable struct Worker
133133
if haskey(map_pid_wrkr, id)
134134
return map_pid_wrkr[id]
135135
end
136-
w=new(id, [], [], false, W_CREATED, Condition(), time(), conn_func)
136+
w=new(id, [], [], false, W_CREATED, Event(), time(), conn_func)
137137
w.initialized = Event()
138138
register_worker(w)
139139
w
@@ -144,7 +144,7 @@ end
144144

145145
function set_worker_state(w, state)
146146
w.state = state
147-
notify(w.c_state; all=true)
147+
notify(w.c_state)
148148
end
149149

150150
function check_worker_state(w::Worker)
@@ -189,7 +189,7 @@ function wait_for_conn(w)
189189
timeout = worker_timeout() - (time() - w.ct_time)
190190
timeout <= 0 && error("peer $(w.id) has not connected to $(myid())")
191191

192-
@async (sleep(timeout); notify(w.c_state; all=true))
192+
@async (sleep(timeout); notify(w.c_state))
193193
wait(w.c_state)
194194
w.state === W_CREATED && error("peer $(w.id) didn't connect to $(myid()) within $timeout seconds")
195195
end

0 commit comments

Comments
 (0)