xvr2::ThreadManager Class Reference

#include <xvr2/ThreadManager.h>

Inheritance diagram for xvr2::ThreadManager:

Inheritance graph
[legend]

List of all members.


Detailed Description

This class brings basic thread creation management functions, and permits running tasks concurrently.

Definition at line 29 of file ThreadManager.h.


Public Types

enum  SchedPolicy { NORMAL, ROUND_ROBIN, FIFO }
 Please use this set of constants to define or stablish a thread execution policy. More...

Public Member Functions

virtual const char * getClassName ()
 Returns the name of the current class.
virtual std::string toString ()

Static Public Member Functions

static void start (Thread *t)
 Spawns thread t execution.
static void start (Thread &t)
static void start (Thread *t, const SchedPolicy pol)
 Spawns a thread object execution.
static void start (Thread &t, const SchedPolicy pol)
static UInt64 start (BackgroundFunction &bf, bool waitfor=true)
 Runs a Background function in a dedicated Thread of execution.
static bool isRunning (Thread *t)
 Tells wheter the t is running or not.
static ThreadgetCurrentThread ()
 Returns the currently running Thread object.
static BackgroundFunctiongetCurrentBackgroundFunction ()
 Returns the currently running BackgroundFunction object.
static const UInt64 getCurrentThreadID ()
 Obtains the numeric identification of the current threaded task.
static unsigned int activeCount ()
 Obtains a count of the currently running concurrent tasks.
static UInt64 numericID (const Thread *t)
 Obtains the numeric of the given Thread object.
static UInt64 numericID (const Thread &t)
 Obtains the numeric of the given Thread object.
static void join (JoinableThread *t)
 Tells the current task to "join" the specified JoinableThread.
static void join (JoinableThread &t)
 Tells the current task to "join" the specified JoinableThread.
static void detach (JoinableThread *t)
 Tells the given thread that no one with expecting it to finish.
static void detach (JoinableThread &t)
 Tells the given thread that no one with expecting it to finish.
static Threading::SchedPolicy getSchedulingPolicy (Thread *t)
static Threading::SchedPolicy getSchedulingPolicy (Thread &t)
static void setSchedulingPolicy (Thread *t, Threading::SchedPolicy pol)
static void setSchedulingPolicy (Thread &t, Threading::SchedPolicy pol)
static void setSchedulingParams (Thread *t, Threading::SchedPolicy pol, int prio)
static void setSchedulingParams (Thread &t, Threading::SchedPolicy pol, int prio)
static void setPriority (Thread *t, int prio)
static void setPriority (Thread &t, int prio)
static bool currentIsThread ()
 Tells if the current thread has been subclassed from the Thread class.
static bool currentIsBackgroundFunction ()
 Tells if the current thread has been subclassed from the BackgroundFunction class.
static bool currentIsMain ()
 Tells if the current thread is the main thread, that is the main() function.
static void testCancellation ()
 Performs a test to see if the current thread has been asked to be cancelled.
static void debugmsg (Object *obj, const char *msg, int linenumber=__LINE__, const char *srcfile=__FILE__)
 Will print a debug message to the screen.
static void debugmsgln (Object *obj, const char *msg, int linenumber=__LINE__, const char *srcfile=__FILE__)

Protected Attributes

std::string __cls_name

Friends

std::ostream & operator<< (std::ostream &stream, const Object &s)

Member Enumeration Documentation

enum xvr2::Threading::SchedPolicy [inherited]

Please use this set of constants to define or stablish a thread execution policy.

Enumerator:
NORMAL  Default scheduling policy, non-realtime.
ROUND_ROBIN  Round Robin based realtime scheduling policy.
FIFO  First In First Out based realtime scheduling policy.

Definition at line 30 of file Threading.h.


Member Function Documentation

static void xvr2::ThreadManager::start ( Thread t  )  [static]

Spawns thread t execution.

Parameters:
t Thread to be started

static void xvr2::ThreadManager::start ( Thread t  )  [static]

static void xvr2::ThreadManager::start ( Thread t,
const SchedPolicy  pol 
) [static]

Spawns a thread object execution.

Parameters:
t Thread object to be started.
pol Scheduling policy

static void xvr2::ThreadManager::start ( Thread t,
const SchedPolicy  pol 
) [static]

static UInt64 xvr2::ThreadManager::start ( BackgroundFunction bf,
bool  waitfor = true 
) [static]

Runs a Background function in a dedicated Thread of execution.

Parameters:
bf The BackgroundFunction to be runned.
waitfor If true the start method wont return until the thread has been succesfully started.

static bool xvr2::ThreadManager::isRunning ( Thread t  )  [static]

Tells wheter the t is running or not.

Parameters:
t The thread to be verified.

static Thread* xvr2::ThreadManager::getCurrentThread (  )  [static]

Returns the currently running Thread object.

Returns:
A pointer to the currently running Thread Object or 0 if the method is called from a non-Thread object.

static BackgroundFunction* xvr2::ThreadManager::getCurrentBackgroundFunction (  )  [static]

Returns the currently running BackgroundFunction object.

Returns:
A pointer to the currently running Thread Object or 0 if the method is called from a non-Thread object.

static const UInt64 xvr2::ThreadManager::getCurrentThreadID (  )  [static]

Obtains the numeric identification of the current threaded task.

Note:
The returned id will match to the id given by the POSIX pthread implementation.
Returns:
The numeric id of the currently running Thread or BackgroundFunction.

static unsigned int xvr2::ThreadManager::activeCount (  )  [static]

Obtains a count of the currently running concurrent tasks.

Returns:
how many Thread or BackgroundFunction objects are concurrently running.

static UInt64 xvr2::ThreadManager::numericID ( const Thread t  )  [static]

Obtains the numeric of the given Thread object.

Note:
This numeric id will match the POSIX's assigned one.
Parameters:
t The Thread object.
Returns:
The concurrent task numeric id.

static UInt64 xvr2::ThreadManager::numericID ( const Thread t  )  [static]

Obtains the numeric of the given Thread object.

Note:
This numeric id will match the POSIX's assigned one.
Parameters:
t The Thread object.
Returns:
The concurrent task numeric id.

static void xvr2::ThreadManager::join ( JoinableThread t  )  [static]

Tells the current task to "join" the specified JoinableThread.

Joining is a thread operation in which the current thread is blocked until another thread finishes.

Parameters:
t The JoinableThread object, which is the thread we will be expecting to finish in order to continue.

static void xvr2::ThreadManager::join ( JoinableThread t  )  [static]

Tells the current task to "join" the specified JoinableThread.

Joining is a thread operation in which the current thread is blocked until another thread finishes.

Parameters:
t The JoinableThread object, which is the thread we will be expecting to finish in order to continue.

static void xvr2::ThreadManager::detach ( JoinableThread t  )  [static]

Tells the given thread that no one with expecting it to finish.

This method will change the thread's execution to a detached state, that is, inmediately after the thread finishes, release all allocated resources from memory since nobody will ever care to joining it.

Parameters:
t The thread we want to have running in a detached state.

static void xvr2::ThreadManager::detach ( JoinableThread t  )  [static]

Tells the given thread that no one with expecting it to finish.

This method will change the thread's execution to a detached state, that is, inmediately after the thread finishes, release all allocated resources from memory since nobody will ever care to joining it.

Parameters:
t The thread we want to have running in a detached state.

static Threading::SchedPolicy xvr2::ThreadManager::getSchedulingPolicy ( Thread t  )  [static]

static Threading::SchedPolicy xvr2::ThreadManager::getSchedulingPolicy ( Thread t  )  [static]

static void xvr2::ThreadManager::setSchedulingPolicy ( Thread t,
Threading::SchedPolicy  pol 
) [static]

static void xvr2::ThreadManager::setSchedulingPolicy ( Thread t,
Threading::SchedPolicy  pol 
) [static]

static void xvr2::ThreadManager::setSchedulingParams ( Thread t,
Threading::SchedPolicy  pol,
int  prio 
) [static]

static void xvr2::ThreadManager::setSchedulingParams ( Thread t,
Threading::SchedPolicy  pol,
int  prio 
) [static]

static void xvr2::ThreadManager::setPriority ( Thread t,
int  prio 
) [static]

static void xvr2::ThreadManager::setPriority ( Thread t,
int  prio 
) [static]

static bool xvr2::ThreadManager::currentIsThread (  )  [static]

Tells if the current thread has been subclassed from the Thread class.

static bool xvr2::ThreadManager::currentIsBackgroundFunction (  )  [static]

Tells if the current thread has been subclassed from the BackgroundFunction class.

static bool xvr2::ThreadManager::currentIsMain (  )  [static]

Tells if the current thread is the main thread, that is the main() function.

Warning:
this method won't diferentiate between natively created threads and the main() function.

static void xvr2::ThreadManager::testCancellation (  )  [static]

Performs a test to see if the current thread has been asked to be cancelled.

When this event occurs no finalization callbacks will by run, not even the onTerminate() handler, only the cancellation callbacks will be run, so you must use these in order to perform any required housekeeping for your threads.

virtual const char* xvr2::Object::getClassName (  )  [virtual, inherited]

Returns the name of the current class.

static void xvr2::Object::debugmsg ( Object obj,
const char *  msg,
int  linenumber = __LINE__,
const char *  srcfile = __FILE__ 
) [static, inherited]

Will print a debug message to the screen.

static void xvr2::Object::debugmsgln ( Object obj,
const char *  msg,
int  linenumber = __LINE__,
const char *  srcfile = __FILE__ 
) [static, inherited]

virtual std::string xvr2::Object::toString (  )  [virtual, inherited]


Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  stream,
const Object s 
) [friend, inherited]


Member Data Documentation

std::string xvr2::Object::__cls_name [protected, inherited]

Definition at line 30 of file Object.h.


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

Generated on Fri Jun 20 22:55:59 2008 for X-VR2 SDK by  doxygen 1.5.5