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 Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(session) ⇒ Context

Returns a new instance of Context.



415
416
417
418
419
420
# File 'lib/mycel.rb', line 415

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

Instance Attribute Details

#sessionObject (readonly)

Returns the value of attribute session.



413
414
415
# File 'lib/mycel.rb', line 413

def session
  @session
end

Instance Method Details

#waitObject



422
423
424
425
426
427
428
429
430
# File 'lib/mycel.rb', line 422

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