Class: CI::Queue::Redis::Base::State

Inherits:
Object
  • Object
show all
Defined in:
lib/ci/queue/redis/base.rb

Instance Method Summary collapse

Constructor Details

#initializeState

Returns a new instance of State.



278
279
280
281
282
# File 'lib/ci/queue/redis/base.rb', line 278

def initialize
  @state = nil
  @mutex = Mutex.new
  @cond = ConditionVariable.new
end

Instance Method Details

#set(*state) ⇒ Object



284
285
286
287
288
289
# File 'lib/ci/queue/redis/base.rb', line 284

def set(*state)
  @state = state
  @mutex.synchronize do
    @cond.broadcast
  end
end

#wait(timeout) ⇒ Object



291
292
293
294
295
296
# File 'lib/ci/queue/redis/base.rb', line 291

def wait(timeout)
  @mutex.synchronize do
    @cond.wait(@mutex, timeout)
  end
  @state
end