Class: Mycel::Channel::Context
- Inherits:
-
Object
- Object
- Mycel::Channel::Context
- Defined in:
- lib/mycel.rb
Defined Under Namespace
Classes: InvalidStateError
Constant Summary collapse
- STATE_INIT =
0- STATE_RUNNING =
1- STATE_STOPPED =
2
Instance Method Summary collapse
-
#initialize(session) ⇒ Context
constructor
A new instance of Context.
- #wait ⇒ Object
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
#wait ⇒ Object
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 |