CVD::Thread Class Reference

#include <thread.h>

Inheritance diagram for CVD::Thread:
Inheritance graph
[legend]

List of all members.

Public Member Functions

pthread_t getID ()
 Get the ID of this thread.
bool isRunning () const
 Returns true if the thread is still running.
void join ()
 This blocks until the thread has actually terminated.
virtual void run ()
 Override this method to do whatever it is the thread should do.
bool shouldStop () const
 Returns true if the stop() method been called, false otherwise.
void start (Runnable *runnable=0)
 Start execution of "run" method in separate thread.
void stop ()
 Tell the thread to stop.
 Thread ()
 Construct a thread. If runnable != 0, use that runnable, else use our own "run" method.
virtual ~Thread ()
 This does not destroy the object until the thread has been terminated.

Static Public Member Functions

static unsigned int count ()
 Returns how many threads are actually running, not including the main thread.
static ThreadgetCurrent ()
 Returns a pointer to the currently running thread.
static void sleep (unsigned int milli)
 Tell the current thread to sleep for milli milliseconds.
static void yield ()
 Tell the current thread to yield the processor.

Static Private Member Functions

static bool init ()
static void * threadproc (void *param)

Private Attributes

pthread_t myID
RunnablemyRunnable
bool myRunningFlag
bool myStopFlag

Static Private Attributes

static unsigned int ourCount
static bool ourInitializedFlag
static pthread_key_t ourKey

Detailed Description

The Thread class encapsulates a thread of execution. It is implemented with POSIX threads. Code that uses this class should link with libpthread and librt (for nanosleep).

Definition at line 13 of file thread.h.


Constructor & Destructor Documentation

CVD::Thread::Thread (  ) 

Construct a thread. If runnable != 0, use that runnable, else use our own "run" method.

virtual CVD::Thread::~Thread (  )  [virtual]

This does not destroy the object until the thread has been terminated.


Member Function Documentation

static unsigned int CVD::Thread::count (  )  [static]

Returns how many threads are actually running, not including the main thread.

static Thread* CVD::Thread::getCurrent (  )  [static]

Returns a pointer to the currently running thread.

pthread_t CVD::Thread::getID (  ) 

Get the ID of this thread.

static bool CVD::Thread::init (  )  [static, private]
bool CVD::Thread::isRunning (  )  const

Returns true if the thread is still running.

void CVD::Thread::join (  ) 

This blocks until the thread has actually terminated.

If the thread is infinite looping, this will block forever!

virtual void CVD::Thread::run (  )  [inline, virtual]

Override this method to do whatever it is the thread should do.

Implements CVD::Runnable.

Reimplemented in CVD::RunnableBatch::RunMessageInThread.

Definition at line 43 of file thread.h.

bool CVD::Thread::shouldStop (  )  const

Returns true if the stop() method been called, false otherwise.

static void CVD::Thread::sleep ( unsigned int  milli  )  [static]

Tell the current thread to sleep for milli milliseconds.

void CVD::Thread::start ( Runnable runnable = 0  ) 

Start execution of "run" method in separate thread.

void CVD::Thread::stop (  ) 

Tell the thread to stop.

This doesn't make the thread actually stop, it just causes shouldStop() to return true.

static void* CVD::Thread::threadproc ( void *  param  )  [static, private]
static void CVD::Thread::yield (  )  [static]

Tell the current thread to yield the processor.


Member Data Documentation

pthread_t CVD::Thread::myID [private]

Definition at line 66 of file thread.h.

Definition at line 65 of file thread.h.

Definition at line 67 of file thread.h.

bool CVD::Thread::myStopFlag [private]

Definition at line 68 of file thread.h.

unsigned int CVD::Thread::ourCount [static, private]

Definition at line 64 of file thread.h.

bool CVD::Thread::ourInitializedFlag [static, private]

Definition at line 61 of file thread.h.

pthread_key_t CVD::Thread::ourKey [static, private]

Definition at line 63 of file thread.h.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines


libcvd
Author(s): Edward Rosten, Paul Smith, Tom Drummond, Gerhard Reitmayr, Ethan Eade, Timothy Gan, Chris Kemp, Georg Klein
autogenerated on Fri Jan 11 09:13:52 2013