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.



652
653
654
655
# File 'lib/sup/util.rb', line 652

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

Instance Method Details

#winner?Boolean

Returns:

  • (Boolean)


657
658
659
# File 'lib/sup/util.rb', line 657

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