\"\" \"\" \"\"
Go backward to Representation
Go up to Threads
Go forward to Basics
RISC-Linz logo

Definition

Thread<R> t
Threadn<R, A1, ..., An> t
Threadn<R, A1, ..., An> t(f, a1, ..., an)
      R (*f)(A1, ..., An)
      Ai ai

Specification: Defines a thread handle t.

  1. In the first form, t may be bound to any thread that returns a result of type R. t is not yet bound to any thread.
  2. In the second form, t may be bound to any thread that takes n arguments of types Ai and returns a result of type R. t is not yet bound to any thread.
  3. In the third form, t is bound to a new thread that returns f(a1, ..., an).
Note: A thread handle of type Threadn<R, A1, ..., An> is implicitly converted to a thread handle of type Thread<R> whenever such a type is expected. Thus e.g. the following is legal:  
Thread<R> s
Threadn<R, A1, ..., An> t(f, a1, ..., an)
s = t
Restrictions: The number of arguments n ranges from 0 to an implementation-dependent constant (currently 4). This range may be extended by defining the corresponding template class.

 

Implementation: The third form is more efficient than the otherwise equivalent form

Threadn<R, A1, ..., An> t
t = Threadn<R, A1, ..., An>(f1, a1, ..., an)
Normally this form is also equivalent to to 
Threadn<R, A1, ..., An> t
t.create(f1, a1, ..., an)
However, if the preprocessor constant RT_THREAD_NOTLAZY is defined before including the header file rt++.h, the declaration is equivalent to
Threadn<R, A1, ..., An> t
t.start(f1, a1, ..., an)

Author: Wolfgang Schreiner
Last Modification: April 12, 1997