Skip to content

Commit

Permalink
Synchronize all accesses to @done
Browse files Browse the repository at this point in the history
* So it is trivially correct.
* Performance seems the same overall.
  • Loading branch information
eregon committed May 15, 2022
1 parent 4baee63 commit 5e0d8e1
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/timeout.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,13 @@ def initialize(thread, timeout, exception_class, message)
@message = message

@mutex = Mutex.new
@done = false
@done = false # protected by @mutex
end

def done?
@done
@mutex.synchronize do
@done
end
end

def expired?(now)
Expand Down

0 comments on commit 5e0d8e1

Please sign in to comment.