Class: Jabber::Stream::ThreadBlock

Inherits:
Object
  • Object
show all
Defined in:
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

Constructor Details

#initialize(block) ⇒ ThreadBlock

Returns a new instance of ThreadBlock.



322
323
324
325
326
# File 'lib/xmpp4r/stream.rb', line 322

def initialize(block)
  @block = block
  @waiter = Semaphore.new
  @exception = nil
end

Instance Method Details

#call(*args) ⇒ Object



327
328
329
# File 'lib/xmpp4r/stream.rb', line 327

def call(*args)
  @block.call(*args)
end

#raise(exception) ⇒ Object



337
338
339
340
# File 'lib/xmpp4r/stream.rb', line 337

def raise(exception)
  @exception = exception
  @waiter.run
end

#waitObject

Raises:

  • (@exception)


330
331
332
333
# File 'lib/xmpp4r/stream.rb', line 330

def wait
  @waiter.wait
  raise @exception if @exception
end

#wakeupObject



334
335
336
# File 'lib/xmpp4r/stream.rb', line 334

def wakeup
  @waiter.run
end