thread.h
Classes | |
This class represents a simple lock used to control concurrency. | |
This class encapsulates a lightweight process running in the same address space as the creator. | |
Statement | |
Defines a critical section protected by the specified lock. | |
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. |
synchronized (lock) ...
synchronized (lock) { ... statements in the critical section ... }
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();