CVD::Thread Class Reference

#include <thread.h>

Inheritance diagram for CVD::Thread:

CVD::Runnable

List of all members.


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.


Public Member Functions

 Thread ()
virtual ~Thread ()
void start (Runnable *runnable=0)
void stop ()
bool shouldStop () const
bool isRunning () const
void join ()
pthread_t getID ()
virtual void run ()

Static Public Member Functions

static unsigned int count ()
static ThreadgetCurrent ()
static void sleep (unsigned int milli)
static void yield ()

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

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

Start execution of "run" method in separate thread.

Referenced by CVD::ReadAheadVideoBuffer< T >::ReadAheadVideoBuffer().

void CVD::Thread::stop (  ) 

Tell the thread to stop.

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

Referenced by CVD::ReadAheadVideoBuffer< T >::~ReadAheadVideoBuffer().

bool CVD::Thread::shouldStop (  )  const

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

Referenced by CVD::ReadAheadVideoBuffer< T >::run().

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!

Referenced by CVD::ReadAheadVideoBuffer< T >::~ReadAheadVideoBuffer().

pthread_t CVD::Thread::getID (  ) 

Get the ID of this thread.

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

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

Implements CVD::Runnable.

Definition at line 43 of file thread.h.

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.

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

Tell the current thread to sleep for milli milliseconds.

static void CVD::Thread::yield (  )  [static]

Tell the current thread to yield the processor.


The documentation for this class was generated from the following file:
Generated on Wed Feb 18 10:23:08 2009 for CVD by  doxygen 1.5.3