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.



639
640
641
642
# File 'lib/sup/util.rb', line 639

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

Instance Method Details

#winner?Boolean

Returns:

  • (Boolean)


644
645
646
# File 'lib/sup/util.rb', line 644

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