Class: Mycel::Channel::Context

Inherits:
Object
  • Object
show all
Defined in:
lib/mycel.rb

Direct Known Subclasses

Command, Job

Defined Under Namespace

Classes: InvalidStateError

Constant Summary collapse

STATE_INIT =
0
STATE_RUNNING =
1
STATE_STOPPED =
2

Instance Method Summary collapse

Constructor Details

#initialize(session) ⇒ Context

Returns a new instance of Context.



377
378
379
380
381
382
# File 'lib/mycel.rb', line 377

def initialize(session)
  @session = session
  @state = STATE_INIT
  @state_lock = Monitor.new
  @waiting_list = []
end

Instance Method Details

#waitObject



384
385
386
387
388
389
390
391
392
# File 'lib/mycel.rb', line 384

def wait
  q = nil
  @state_lock.synchronize {
    return if @state == STATE_STOPPED
    q = Queue.new
    @waiting_list.push q
  }
  q.deq
end