libpsynth 0.2.1
Public Member Functions
psynth::thread Class Reference

A Thread is an objects to execute pieces of code concurrently allowing shared access to the process memory. More...

#include <thread.hpp>

Inheritance diagram for psynth::thread:
Inheritance graph
[legend]
Collaboration diagram for psynth::thread:
Collaboration graph
[legend]

List of all members.

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.

Detailed Description

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.


Constructor & Destructor Documentation

psynth::thread::thread ( runnable obj) [inline]

Contructor that attaches a runnable object to the Thread.

Parameters:
objThe runnable object that will be attached to the thread.
psynth::thread::thread ( thread_delegate  func) [inline]

Constructor that attaches a delegate to the Thread.

Parameters:
funcThe functor that will be attached to thread.

Member Function Documentation

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.

Parameters:
funcThe delegate to attach.
void psynth::thread::set ( runnable obj) [inline]

Sets a runnable object to attach to the Thread.

Parameters:
objThe Runnable to attach.
void psynth::thread::start ( runnable obj) [inline]

Attaches a Runnable and starts its concurrent execution.

Parameters:
objThe runnable to attach.
void psynth::thread::start ( thread_delegate  func) [inline]

Attaches a delegate and starts its concurrent execution.

Parameters:
funcThe delegate to attach.
void psynth::thread::start ( ) [inline]

Starts the concurrent execution of the attached entity.


The documentation for this class was generated from the following file: