class Celluloid::IO::Stream::Latch
Perform an operation exclusively, uncontested by other tasks
Public Class Methods
new()
click to toggle source
# File lib/celluloid/io/stream.rb, line 370 def initialize @owner = nil @waiters = 0 @condition = Celluloid::Condition.new end
Public Instance Methods
synchronize() { || ... }
click to toggle source
Synchronize an operation across all tasks in the current actor
# File lib/celluloid/io/stream.rb, line 377 def synchronize actor = Thread.current[:celluloid_actor] return yield unless actor if @owner || @waiters > 0 @waiters += 1 @condition.wait @waiters -= 1 end @owner = Task.current begin ret = yield ensure @owner = nil @condition.signal if @waiters > 0 end ret end