The Open Master Hearing Aid (openMHA)
openMHA
Open community platform for hearing aid algorithm research
|
A very simple class for portable threads. More...
Public Types | |
enum | { PREPARED , RUNNING , FINISHED } |
The current state of the thread. More... | |
typedef void *(* | thr_f) (void *) |
The thread function signature to use with this class. More... | |
Public Member Functions | |
Thread (thr_f func, void *arg=0) | |
Constructor starts a new thread. More... | |
virtual | ~Thread () |
The destructor should only be called when the Thread is finished. More... | |
virtual void | run () |
The internal method that delegated the new thread to the registered Thread function. More... | |
Public Attributes | |
Async_Notify | thread_finish_event |
Event will be triggered when the thread exits. More... | |
enum MHA_TCP::Thread:: { ... } | state |
The current state of the thread. More... | |
thr_f | thread_func |
The thread function that the client has registered. More... | |
void * | thread_arg |
The argument that the client wants to be handed through to the thread function. More... | |
MHA_Error * | error |
The MHA_Error that caused the thread to abort, if any. More... | |
Protected Member Functions | |
Thread () | |
Default constructor may only be used by derived classes that want to start the thread themselves. More... | |
Protected Attributes | |
void * | arg |
The argument for the client's thread function. More... | |
void * | return_value |
The return value from the client's thread function is stored here When that function returns. More... | |
Private Attributes | |
pthread_t | thread_handle |
The posix thread handle. More... | |
pthread_attr_t | thread_attr |
The posix thread attribute structure. More... | |
A very simple class for portable threads.
typedef void*(* MHA_TCP::Thread::thr_f) (void *) |
The thread function signature to use with this class.
Derive from this class and call protected standard constructor to start threads differently.
|
protected |
Default constructor may only be used by derived classes that want to start the thread themselves.
Thread::Thread | ( | Thread::thr_f | func, |
void * | arg = 0 |
||
) |
Constructor starts a new thread.
func | The function to be executed by the thread. |
arg | The argument given to pass to the thread function. |
|
virtual |
The destructor should only be called when the Thread is finished.
There is preliminary support for forceful thread cancellation in the destructor, but probably not very robust or portable..
|
virtual |
The internal method that delegated the new thread to the registered Thread function.
|
private |
The posix thread handle.
|
private |
The posix thread attribute structure.
Required for starting a thread in detached state. Detachment is required to eliminate the need for joining this thread.
|
protected |
The argument for the client's thread function.
|
protected |
The return value from the client's thread function is stored here When that function returns.
Async_Notify MHA_TCP::Thread::thread_finish_event |
Event will be triggered when the thread exits.
enum { ... } MHA_TCP::Thread::state |
The current state of the thread.
thr_f MHA_TCP::Thread::thread_func |
The thread function that the client has registered.
void* MHA_TCP::Thread::thread_arg |
The argument that the client wants to be handed through to the thread function.