Class: Jabber::Stream::ThreadBlock

Inherits:
Object
  • Object
show all
Defined in:
lib/vendor/xmpp4r/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.



266
267
268
269
270
# File 'lib/vendor/xmpp4r/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/vendor/xmpp4r/lib/xmpp4r/stream.rb', line 271

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

#raise(exception) ⇒ Object



282
283
284
285
# File 'lib/vendor/xmpp4r/lib/xmpp4r/stream.rb', line 282

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

#waitObject

Raises:

  • (@exception)


274
275
276
277
# File 'lib/vendor/xmpp4r/lib/xmpp4r/stream.rb', line 274

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

#wakeupObject



278
279
280
281
# File 'lib/vendor/xmpp4r/lib/xmpp4r/stream.rb', line 278

def wakeup
  # TODO: Handle threadblock removal if !alive?
  @waiter.run
end