Class: FinishLine
Overview
easy thread-safe class for determining who’s the “winner” in a race (i.e. first person to hit the finish line
Instance Method Summary collapse
-
#initialize ⇒ FinishLine
constructor
A new instance of FinishLine.
- #winner? ⇒ Boolean
Constructor Details
#initialize ⇒ FinishLine
Returns a new instance of FinishLine.
639 640 641 642 |
# File 'lib/sup/util.rb', line 639 def initialize @m = Mutex.new @over = false end |
Instance Method Details
#winner? ⇒ Boolean
644 645 646 |
# File 'lib/sup/util.rb', line 644 def winner? @m.synchronize { !@over && @over = true } end |