|
libpsynth 0.2.1
|
A Thread is an objects to execute pieces of code concurrently allowing shared access to the process memory. More...
#include <thread.hpp>


Public Member Functions | |
| thread (runnable &obj) | |
| Contructor that attaches a runnable object to the Thread. | |
| thread (thread_delegate func) | |
| Constructor that attaches a delegate to the Thread. | |
| void | set (runnable &obj) |
| Sets a runnable object to attach to the Thread. | |
| void | set (thread_delegate func) |
| Sets a delegate to attach to the Thread. | |
| void | start () |
| Starts the concurrent execution of the attached entity. | |
| void | start (runnable &obj) |
| Attaches a Runnable and starts its concurrent execution. | |
| void | start (thread_delegate func) |
| Attaches a delegate and starts its concurrent execution. | |
| void | join () |
| Blocks untill the last started thread finished. | |
A Thread is an objects to execute pieces of code concurrently allowing shared access to the process memory.
You can attach to a thread a Runnable object or a ThreadDelegate. When you run start() the Runnable run() function or the function to which the ThreadDelegate points will be called in a new thread, this means that the normal flow of the code will contine but the function will run concurrently too.
Mutex, RWMutex and Condition classes provide some synchronization methods to avoid race conditions in concurrent code.
| psynth::thread::thread | ( | runnable & | obj | ) | [inline] |
Contructor that attaches a runnable object to the Thread.
| obj | The runnable object that will be attached to the thread. |
| psynth::thread::thread | ( | thread_delegate | func | ) | [inline] |
Constructor that attaches a delegate to the Thread.
| func | The functor that will be attached to thread. |
| void psynth::thread::join | ( | ) | [inline] |
Blocks untill the last started thread finished.
Note that if you call start() twice you will be only able to join the last called function. If you want to be able to join both create a different Thread instance for each.
| void psynth::thread::set | ( | thread_delegate | func | ) | [inline] |
Sets a delegate to attach to the Thread.
| func | The delegate to attach. |
| void psynth::thread::set | ( | runnable & | obj | ) | [inline] |
Sets a runnable object to attach to the Thread.
| obj | The Runnable to attach. |
| void psynth::thread::start | ( | runnable & | obj | ) | [inline] |
Attaches a Runnable and starts its concurrent execution.
| obj | The runnable to attach. |
| void psynth::thread::start | ( | thread_delegate | func | ) | [inline] |
Attaches a delegate and starts its concurrent execution.
| func | The delegate to attach. |
| void psynth::thread::start | ( | ) | [inline] |
Starts the concurrent execution of the attached entity.
1.7.4