Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

ONE::util::Thread Class Reference

List of all members.

Detailed Description

a thread abstraction object

The work done in the new thread may be specified either by passing a Task object to it or by subclassing the Thread class and overwriting the Thread::run function. Note that the creation of a Thread object does not actually generate a new thread. The thread is not created until Thread::start is called.

Author:
Daniel Seibert


Public Types

typedef Uint32 time

Public Member Functions

ThreadID getID () const
 retrieves this thread's id
bool isRunning () const
 checks if this thread is running
void setTask (Task *)
 sets this thread's task object
void sleep (time ms) const
 pauses the thread for at least ms milliseconds
void start ()
 launches the thread
 Thread (Task *t=0)
 creates a thread with the given task
void yield () const
 allows other threads to execute
virtual ~Thread ()

Static Public Member Functions

static ThreadID getCurrentID ()
 retrieves the calling thread's id
static bool isMainThread ()
 checks if the calling thread is the main thread

Static Public Attributes

static const ThreadID INVALID_ID

Protected Member Functions

virtual void run ()
 the function executed by this thread

Friends

void waitFor (Thread *)
 blocks the current thread until the given thread dies


Member Typedef Documentation

typedef Uint32 ONE::util::Thread::time
 


Constructor & Destructor Documentation

ONE::util::Thread::Thread Task t = 0  ) 
 

creates a thread with the given task

Note that the thread is not launched until Thread::start is called.

virtual ONE::util::Thread::~Thread  )  [virtual]
 


Member Function Documentation

static ThreadID ONE::util::Thread::getCurrentID  )  [static]
 

retrieves the calling thread's id

ThreadID ONE::util::Thread::getID  )  const
 

retrieves this thread's id

If this thread is not running, this function returns INVALID_ID

static bool ONE::util::Thread::isMainThread  )  [static]
 

checks if the calling thread is the main thread

The main thread is the thread that the program started with.

bool ONE::util::Thread::isRunning  )  const
 

checks if this thread is running

virtual void ONE::util::Thread::run  )  [protected, virtual]
 

the function executed by this thread

The default implementation calls the Task 's Task::run function.

void ONE::util::Thread::setTask Task  ) 
 

sets this thread's task object

Exceptions:
InvalidStateException if the thread is currently running

void ONE::util::Thread::sleep time  ms  )  const
 

pauses the thread for at least ms milliseconds

void ONE::util::Thread::start  ) 
 

launches the thread

This function creates the actual system thread, launches it and then returns. It does not wait for the run function to finish.

Exceptions:
InvalidStateException if the thread is already running

void ONE::util::Thread::yield  )  const
 

allows other threads to execute


Friends And Related Function Documentation

void waitFor Thread  )  [friend]
 

blocks the current thread until the given thread dies

Exceptions:
InvalidArgumentException if the calling thread equals the given thread


Member Data Documentation

const ThreadID ONE::util::Thread::INVALID_ID [static]
 


Generated on Wed Sep 7 19:03:33 2005 for ONEngine by  doxygen 1.4.3