class Thread
Thread child = fork(fn); ... code for the parent thread ... join(child);This code calls
fn
so that it runs in parallel with the
parent code.
Constructor | |
Creates an inactive thread variable that will typically be overwritten by the result of a fork call. | |
Method | |
Converts the thread to a string. | |
Functions | |
fork(fn, data) | Creates a child thread that calls fn in an address space shared with the current thread. |
Returns the currently executing thread. | |
Waits for the specified thread to finish before proceeding. | |
Yields the processor to allow another thread to run. |
Thread();
fork
call.
Usage:
Thread thread;
string toString();
Usage:
string str = thread.toString();
Thread fork(void (*fn)()); Thread fork(void (*fn)(ClientType& data), ClientType& data);
fn
in an address space
shared with the current thread. The second form makes it possible to
pass an argument to fn
, which may be of any type.
Usage:
Thread child = fork(fn); Thread child = fork(fn, data);
void join(Thread& thread);
Usage:
join(thread);
void yield();
Usage:
yield();
Thread getCurrentThread();
Usage:
Thread self = getCurrentThread();