Class: FinishLine

Inherits:
Object show all
Defined in:
lib/sup/util.rb

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

Constructor Details

#initializeFinishLine

Returns a new instance of FinishLine.



637
638
639
640
# File 'lib/sup/util.rb', line 637

def initialize
  @m = Mutex.new
  @over = false
end

Instance Method Details

#winner?Boolean

Returns:

  • (Boolean)


642
643
644
# File 'lib/sup/util.rb', line 642

def winner?
  @m.synchronize { !@over && @over = true }
end