#include <vpr/Thread/BaseThread.h>
Inheritance diagram for vpr::BaseThread:


Public Types | |
| enum | VPRThreadPriority { VPR_PRIORITY_LOW, VPR_PRIORITY_NORMAL, VPR_PRIORITY_HIGH, VPR_PRIORITY_URGENT } |
| enum | VPRThreadScope { VPR_LOCAL_THREAD, VPR_GLOBAL_THREAD } |
| enum | VPRThreadState { VPR_JOINABLE_THREAD, VPR_UNJOINABLE_THREAD } |
Public Member Functions | |
| BaseThread () | |
| virtual | ~BaseThread () |
| virtual void | setFunctor (BaseThreadFunctor *functorPtr)=0 |
| Sets the thread's functor--the code that will get executed. | |
| virtual vpr::ReturnStatus | start ()=0 |
| Starts the thread's execution. | |
| TSTable * | getTSTable () |
| Gets the Thread specific data table. | |
| virtual int | join (void **status=0) |
| Causes the calling thread wait for the termination of this thread. | |
| virtual int | resume () |
| Resumes the execution of this thread (if it was previously suspended using suspend()). | |
| virtual int | suspend () |
| Suspends the execution of this thread. | |
| virtual int | getPrio (VPRThreadPriority *prio) |
| Gets this thread's current priority. | |
| virtual int | setPrio (VPRThreadPriority prio) |
| Sets this thread's priority. | |
| vpr::Int32 | getTID () |
| Gets the "thread ID" of this vpr::BaseThread object. | |
| bool | valid () |
| Is this a valid thread? | |
| virtual int | kill (int signum) |
Sends the specified signal to this thread (not necessarily SIGKILL). | |
| virtual void | kill () |
| Kills (cancels) this thread. | |
| virtual std::ostream & | outStream (std::ostream &out) |
| Ouputs the state of the object. | |
Static Public Member Functions | |
| static TSTable * | getGlobalTSTable () |
| Get the Thread the global thread specific data table. | |
Protected Member Functions | |
| void | registerThread (bool successfulCreation) |
| After the object has been created, call this routine to complete initialization. | |
| void | unregisterThread () |
| void | createThreadId () |
| Initializes the state of the object. | |
Protected Attributes | |
| vpr::Int32 | mThreadId |
Provides functionality that is common to all threading implementations.
Definition at line 73 of file BaseThread.h.
| VPR_PRIORITY_LOW | The lowest possible priority. |
| VPR_PRIORITY_NORMAL | The most common priority. |
| VPR_PRIORITY_HIGH | Slightly higher priority. |
| VPR_PRIORITY_URGENT | The highest priority. |
Definition at line 76 of file BaseThread.h.
00077 { 00078 VPR_PRIORITY_LOW, 00079 VPR_PRIORITY_NORMAL, 00080 VPR_PRIORITY_HIGH, 00081 VPR_PRIORITY_URGENT 00082 };
Definition at line 84 of file BaseThread.h.
00085 { 00086 VPR_LOCAL_THREAD, 00087 VPR_GLOBAL_THREAD 00088 };
| VPR_JOINABLE_THREAD | The thread can be reattached later. |
| VPR_UNJOINABLE_THREAD | The thread cannot be attached with join(). |
Definition at line 90 of file BaseThread.h.
00091 { 00092 VPR_JOINABLE_THREAD, 00093 VPR_UNJOINABLE_THREAD 00094 };
| vpr::BaseThread::BaseThread | ( | ) | [inline] |
| virtual vpr::BaseThread::~BaseThread | ( | ) | [inline, virtual] |
| virtual void vpr::BaseThread::setFunctor | ( | BaseThreadFunctor * | functorPtr | ) | [pure virtual] |
Sets the thread's functor--the code that will get executed.
Implemented in vpr::ThreadNSPR, vpr::ThreadPosix, and vpr::ThreadSGI.
| virtual vpr::ReturnStatus vpr::BaseThread::start | ( | ) | [pure virtual] |
Starts the thread's execution.
Implemented in vpr::ThreadNSPR, vpr::ThreadPosix, and vpr::ThreadSGI.
| TSTable* vpr::BaseThread::getTSTable | ( | ) | [inline] |
Gets the Thread specific data table.
Definition at line 119 of file BaseThread.h.
| static TSTable* vpr::BaseThread::getGlobalTSTable | ( | ) | [inline, static] |
Get the Thread the global thread specific data table.
This table is shared by all threads that were not created by VPR.
Definition at line 128 of file BaseThread.h.
| void vpr::BaseThread::registerThread | ( | bool | successfulCreation | ) | [protected] |
After the object has been created, call this routine to complete initialization.
It is done this way because I need to call this based on stuff that happens in derived class's constructor.
| successfulCreation | Did the thread get created correctly? |
Definition at line 82 of file BaseThread.cpp.
References createThreadId(), mThreadId, and vprASSERT.
Referenced by vpr::ThreadSGI::start(), vpr::ThreadPosix::start(), vpr::ThreadNSPR::start(), and vpr::ThreadPosix::startThread().
00083 { 00084 if(succesfulCreation) // Succeed 00085 { 00086 createThreadId(); 00087 Thread* thread_ptr = dynamic_cast<Thread*>(this); 00088 vprASSERT(NULL != thread_ptr); 00089 ThreadManager::instance()->addThread(thread_ptr); // Add the thread to the table 00090 } 00091 else 00092 { 00093 mThreadId = -1; // We have an invalid thread 00094 } 00095 }
| void vpr::BaseThread::unregisterThread | ( | ) | [protected] |
Definition at line 97 of file BaseThread.cpp.
References vprASSERT.
Referenced by vpr::ThreadNSPR::~ThreadNSPR(), vpr::ThreadPosix::~ThreadPosix(), and vpr::ThreadSGI::~ThreadSGI().
00098 { 00099 vpr::Thread* thread_ptr = dynamic_cast<vpr::Thread*>(this); 00100 vprASSERT(NULL != thread_ptr); 00101 vpr::ThreadManager::instance()->removeThread(thread_ptr); 00102 }
| virtual int vpr::BaseThread::join | ( | void ** | status = 0 |
) | [inline, virtual] |
Causes the calling thread wait for the termination of this thread.
| status | Current state of the terminating thread when that thread calls the exit routine (optional). |
-1 is returned on an error condition.
Reimplemented in vpr::ThreadNSPR, vpr::ThreadPosix, and vpr::ThreadSGI.
Definition at line 204 of file BaseThread.h.
| virtual int vpr::BaseThread::resume | ( | ) | [inline, virtual] |
Resumes the execution of this thread (if it was previously suspended using suspend()).
-1 is returned otherwise.
Reimplemented in vpr::ThreadNSPR, vpr::ThreadPosix, and vpr::ThreadSGI.
Definition at line 217 of file BaseThread.h.
| virtual int vpr::BaseThread::suspend | ( | void | ) | [inline, virtual] |
Suspends the execution of this thread.
-1 is returned otherwise.
Reimplemented in vpr::ThreadNSPR, vpr::ThreadPosix, and vpr::ThreadSGI.
Definition at line 228 of file BaseThread.h.
| virtual int vpr::BaseThread::getPrio | ( | VPRThreadPriority * | prio | ) | [inline, virtual] |
Gets this thread's current priority.
| prio | Pointer to an int variable that will have the thread's priority stored in it. |
-1 is returned if the priority could not be read.
Definition at line 245 of file BaseThread.h.
| virtual int vpr::BaseThread::setPrio | ( | VPRThreadPriority | prio | ) | [inline, virtual] |
Sets this thread's priority.
| prio | The new priority for this thread. |
-1 is returned otherwise.
Definition at line 259 of file BaseThread.h.
| vpr::Int32 vpr::BaseThread::getTID | ( | ) | [inline] |
Gets the "thread ID" of this vpr::BaseThread object.
This is a unique integer value assigned when the thread was created.
Otherwise, the value returned is this thread's ID.
Definition at line 273 of file BaseThread.h.
Referenced by vpr::ThreadManager::addThread(), vpr::ThreadManager::removeThread(), and vpr::ThreadNSPR::start().
00274 { 00275 return mThreadId; 00276 }
| bool vpr::BaseThread::valid | ( | ) | [inline] |
Is this a valid thread?
Definition at line 289 of file BaseThread.h.
00290 { 00291 return (mThreadId != -1); 00292 }
| virtual int vpr::BaseThread::kill | ( | int | signum | ) | [inline, virtual] |
Sends the specified signal to this thread (not necessarily SIGKILL).
| signum | The signal to send to the specified thread. |
-1 is returned if an error occurred.
Reimplemented in vpr::ThreadNSPR, vpr::ThreadPosix, and vpr::ThreadSGI.
Definition at line 304 of file BaseThread.h.
| virtual void vpr::BaseThread::kill | ( | ) | [inline, virtual] |
Kills (cancels) this thread.
Reimplemented in vpr::ThreadNSPR, vpr::ThreadPosix, and vpr::ThreadSGI.
Definition at line 315 of file BaseThread.h.
| std::ostream & vpr::BaseThread::outStream | ( | std::ostream & | out | ) | [virtual] |
Ouputs the state of the object.
Reimplemented in vpr::ThreadNSPR, vpr::ThreadPosix, and vpr::ThreadSGI.
Definition at line 58 of file BaseThread.cpp.
References mThreadId.
Referenced by vpr::ThreadSGI::outStream(), and vpr::ThreadPosix::outStream().
00059 { 00060 out.setf(std::ios::right); 00061 out << std::setw(3) << mThreadId; 00062 out.unsetf(std::ios::right); 00063 return out; 00064 }
| void vpr::BaseThread::createThreadId | ( | ) | [inline, protected] |
Initializes the state of the object.
Definition at line 327 of file BaseThread.h.
Referenced by registerThread().
00328 { 00329 mThreadId = getNextThreadId(); 00330 }
vpr::Int32 vpr::BaseThread::mThreadId [protected] |
1.5.1