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

- (ThreadBlock) initialize(block)



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

- (Object) call(*args)



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

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

- (Object) raise(exception)



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

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

- (Object) wait

Raises:

  • (@exception)


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

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

- (Object) wakeup



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

def wakeup
  @waiter.run
end