mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[ruby/timeout] Synchronize all accesses to @done
* So it is trivially correct.
* Performance seems the same overall.
5e0d8e1637
This commit is contained in:
parent
354cd6f210
commit
240ac9eaa8
1 changed files with 4 additions and 2 deletions
|
@ -67,12 +67,14 @@ module Timeout
|
||||||
@message = message
|
@message = message
|
||||||
|
|
||||||
@mutex = Mutex.new
|
@mutex = Mutex.new
|
||||||
@done = false
|
@done = false # protected by @mutex
|
||||||
end
|
end
|
||||||
|
|
||||||
def done?
|
def done?
|
||||||
|
@mutex.synchronize do
|
||||||
@done
|
@done
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def expired?(now)
|
def expired?(now)
|
||||||
now >= @deadline and !done?
|
now >= @deadline and !done?
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue