Class

ThreadsWait

Inheritance
< Object

This class watches for termination of multiple threads. Basic functionality (wait until specified threads have terminated) can be accessed through the class method ThreadsWait::all_waits. Finer control can be gained using instance methods.

Example:

  ThreadsWait.all_wait(thr1, thr2, ...) do |t|
    STDERR.puts "Thread #{t} has terminated."
  end

Constants

Name   Description
RCS_ID = '-$Id: thwait.rb,v 1.3 1998/06/26 03:19:34 keiju Exp keiju $-'

Attributes

Name Visibility R/W Description
threads public R Returns the array of threads in the wait queue.

Methods

Class

Visibility Signature
public all_waits (*threads) {|thread| ...}
public new (*threads)

Instance

Visibility Signature
public all_waits () {|th if block_given?| ...}
public empty? ()
public finished? ()
public join (*threads)
public join_nowait (*threads)
public next_wait (nonblock = nil)

Class Method Detail

all_waits(*threads) {|thread| ...}

Waits until all specified threads have terminated. If a block is provided, it is executed for each thread termination.

new(*threads)

Creates a ThreadsWait object, specifying the threads to wait on. Non-blocking.

Instance Method Detail

all_waits() {|th if block_given?| ...}

Waits until all of the specified threads are terminated. If a block is supplied for the method, it is executed for each thread termination.

Raises exceptions in the same manner as next_wait.

empty?()

Returns true if there are no threads to be synchronized.

finished?()

Returns true if any thread has terminated.

join(*threads)

Waits for specified threads to terminate.

join_nowait(*threads)

Specifies the threads that this object will wait for, but does not actually wait.

next_wait(nonblock = nil)

Waits until any of the specified threads has terminated, and returns the one that does.

If there is no thread to wait, raises ErrNoWaitingThread. If nonblock is true, and there is no terminated thread, raises ErrNoFinishedThread.