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 Attribute Summary collapse
-
#session ⇒ Object
readonly
Returns the value of attribute session.
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.
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
#session ⇒ Object (readonly)
Returns the value of attribute session.
413 414 415 |
# File 'lib/mycel.rb', line 413 def session @session end |
Instance Method Details
#wait ⇒ Object
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 |