Class: Jabber::Stream::ThreadBlock
- Defined in:
- lib/gems/xmpp4r-0.4/lib/xmpp4r/stream.rb
Overview
This is used by Jabber::Stream internally to keep track of any blocks which were passed to Stream#send.
Instance Method Summary collapse
- #call(*args) ⇒ Object
-
#initialize(block) ⇒ ThreadBlock
constructor
A new instance of ThreadBlock.
- #raise(exception) ⇒ Object
- #wait ⇒ Object
- #wakeup ⇒ Object
Constructor Details
#initialize(block) ⇒ ThreadBlock
Returns a new instance of ThreadBlock.
266 267 268 269 270 |
# File 'lib/gems/xmpp4r-0.4/lib/xmpp4r/stream.rb', line 266 def initialize(block) @block = block @waiter = Semaphore.new @exception = nil end |
Instance Method Details
#call(*args) ⇒ Object
271 272 273 |
# File 'lib/gems/xmpp4r-0.4/lib/xmpp4r/stream.rb', line 271 def call(*args) @block.call(*args) end |
#raise(exception) ⇒ Object
282 283 284 285 |
# File 'lib/gems/xmpp4r-0.4/lib/xmpp4r/stream.rb', line 282 def raise(exception) @exception = exception @waiter.run end |
#wait ⇒ Object
274 275 276 277 |
# File 'lib/gems/xmpp4r-0.4/lib/xmpp4r/stream.rb', line 274 def wait @waiter.wait raise @exception if @exception end |
#wakeup ⇒ Object
278 279 280 281 |
# File 'lib/gems/xmpp4r-0.4/lib/xmpp4r/stream.rb', line 278 def wakeup # TODO: Handle threadblock removal if !alive? @waiter.run end |