Avoid possible race in ConditionVariable where new processes begin waiting while #broadcast is running.
This commit is contained in:
parent
cc663a8d7f
commit
edc927709a
|
@ -10,7 +10,9 @@ module ProcessShared
|
||||||
end
|
end
|
||||||
|
|
||||||
def broadcast
|
def broadcast
|
||||||
waiting.times { @sem.post }
|
@internal.synchronize do
|
||||||
|
@waiting.read_int.times { @sem.post }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def signal
|
def signal
|
||||||
|
@ -38,12 +40,6 @@ module ProcessShared
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def waiting
|
|
||||||
@internal.synchronize do
|
|
||||||
@waiting.read_int
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def inc_waiting(val = 1)
|
def inc_waiting(val = 1)
|
||||||
@internal.synchronize do
|
@internal.synchronize do
|
||||||
@waiting.write_int(@waiting.read_int + val)
|
@waiting.write_int(@waiting.read_int + val)
|
||||||
|
|
Loading…
Reference in New Issue