File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -145,6 +145,7 @@ function wait(c::GenericCondition; first::Bool=false, timeout::Real=0.0)
145
145
token = unlockall (c. lock)
146
146
147
147
timer:: Union{Timer, Nothing} = nothing
148
+ waiter_left = Threads. Atomic {Bool} (false )
148
149
if timeout > 0.0
149
150
timer = Timer (timeout)
150
151
# start a task to wait on the timer
@@ -160,7 +161,7 @@ function wait(c::GenericCondition; first::Bool=false, timeout::Real=0.0)
160
161
# Confirm that the waiting task is still in the wait queue and remove it. If
161
162
# the task is not in the wait queue, it must have been notified already so we
162
163
# don't do anything here.
163
- if ct. queue == c. waitq
164
+ if ! waiter_left[] && ct. queue == c. waitq
164
165
dosched = true
165
166
Base. list_deletefirst! (c. waitq, ct)
166
167
end
@@ -174,7 +175,10 @@ function wait(c::GenericCondition; first::Bool=false, timeout::Real=0.0)
174
175
175
176
try
176
177
res = wait ()
177
- timer === nothing || close (timer)
178
+ if timer != = nothing
179
+ close (timer)
180
+ waiter_left[] = true
181
+ end
178
182
return res
179
183
catch
180
184
q = ct. queue; q === nothing || Base. list_deletefirst! (q:: IntrusiveLinkedList{Task} , ct)
You can’t perform that action at this time.
0 commit comments