Discrete Dipole Approximation Project  1.0
Plugin based Discrete Dipole Approximation (DDA) software package.
Thread::Thread Class Reference

Detailed Description

#include "thread.h"
void * do(void * arg) {
...
}
int main() {
for (int i=0;i<10;i++) {
t[i] = new Thread::Thread(do);
t[i].Run(); }
for (int i=0;i<10;i++) {
t[i].Join(0); } }

#include "thread.h"

Public Member Functions

 Thread (void *(*func(void *)), void *arg)
 Constructor. More...
 
 ~Thread ()
 Destructor. More...
 
virtual void * Entry (void *arg)
 Thread entry point, this function simply calls the function pointer pass to the Constructor. More...
 
bool Join (unsigned long timeout, bool execpt=true)
 Join the thread, blocking for timeout seconds or thread completion which ever is shorter. More...
 
bool Run ()
 Lanuches the thread. More...
 

Constructor & Destructor Documentation

Thread::Thread::Thread ( void *(**  void)
inline

Constructs a new Thread object. This will run func with arg when started.

Parameters
[in]voidfunction to run when thread starts.
Thread::Thread::~Thread ( )
inline

Joins the thread and destroys the internal thread handle.

Member Function Documentation

void * Thread::Thread::Entry ( void *  arg)
virtual
Parameters
[in]argargument to passed on object creation.
bool Thread::Thread::Join ( unsigned long  timeout,
bool  execpt = true 
)
inline

If timeout is 0 block until thread completion.

Returns
true if thread completes, false on timeout
Exceptions
TimeoutExceptionRaised if except is true (default)
Parameters
[in]timeoutTime limit for blocking.
[in]execptRaise exception on timeout
bool Thread::Thread::Run ( )
inline
Returns
true if thread starts ok, false otherwise.