Class: Contrails::Semaphore
- Inherits:
-
Object
- Object
- Contrails::Semaphore
- Includes:
- EventMachine::Deferrable
- Defined in:
- lib/contrails/semaphore.rb
Instance Method Summary collapse
-
#initialize(n, results) ⇒ Semaphore
constructor
A new instance of Semaphore.
- #signal ⇒ Object
Constructor Details
#initialize(n, results) ⇒ Semaphore
Returns a new instance of Semaphore.
8 9 10 11 12 |
# File 'lib/contrails/semaphore.rb', line 8 def initialize(n, results) @value = n @results = results @mutex = Mutex.new end |
Instance Method Details
#signal ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/contrails/semaphore.rb', line 14 def signal @mutex.synchronize do if(@value -= 1) == 0 self.succeed(*Contrails::Helpers.unwrap_array(@results)) end end end |