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.



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

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

Instance Method Details

#call(*args) ⇒ Object



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

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

#raise(exception) ⇒ Object



344
345
346
347
# File 'lib/xmpp4r/stream.rb', line 344

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

#waitObject

Raises:

  • (@exception)


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

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

#wakeupObject



341
342
343
# File 'lib/xmpp4r/stream.rb', line 341

def wakeup
  @waiter.run
end