Topics
:Overview
Thread Variables
Member Functions
Error Handling
The vbThread_t class is a data structure used to initialize and store thread variables prior to and after thread creation. Thread variables are set by the vbThread base class and handled in a consistent manner across multiple platforms. A complete set of thread variables will be made available to classes derived from the vbThread base class and to the application though the use of vbThread_t pointers.
Thread variables are used to store various thread information that can be used by the application to perform an operation based on the particular value. The variables are accessed directly by the vbThread class and the low-level thread API wrapper class. An application can access these variables through the vbThread_t member functions.
vbThread *entry - Pointer to this thread's entry function. The vbThread base class sets this value when a new thread is constructed or created. The thread API wrapper class uses this variable to access the thread's entry function.
vbStackSizeType stack_size - Variable used to set the thread's stack size if the default stack size is not sufficient to execute the thread's entry function. A value of zero will set the stack size to the default value of the native thread API.
vbThreadPriority thread_priority - Variable used to set the thread's priority. The thread priority value must match one of the enumerated integer constants defined in the vbThreadPriority enumeration.
vbThreadPriorityClass thread_priority_class - Variable used to set the thread's scheduling policy. The thread priority class value must match one of the enumerated integer constants defined in the vbThreadPriorityClass enumeration.
vbThreadState thread_state - Variable used by the vbThread base class to set the thread's current state. This value will match one of the integer constants defined in the vbThreadState enumeration.
vbThreadID thread_id - Variable used to store the platform specific thread ID after the thread has been created.
vbThreadAttribute thread_attribute - Platform specific thread attribute used to initialize a thread during creation.
vbThreadType thread_type - Variable used to set the thread's state. By default all threads are created as joinable threads. This value will match one of the integer constants defined in the vbThreadType enumeration.
vbThreadError thread_error - Variable used to hold the last error reported following a thread operation. This value will match one of the integer constants defined in the vbThreadError enumeration.
vbThreadExitCode thread_exit_code - Variable used to store the exit code returned by the thread's entry function or the value set following a vbThread::ExitThread() call.
void *thread_parm - Optional thread parameter pointer used to pass a parameter to thread when a new thread is constructed or created.
vbThreadObjectID thread_oid - Variable used to store the optional object ID of a thread. The OID variable can be used by an application in place of the platform-specific thread ID to identify threads in a consistent manner regardless of the platform used.
vbThreadClassID thread_cid - Variable used to store the optional class ID of a thread. The CID and OID variables can be used by an application in place of the platform-specific thread ID to identify threads in a consistent manner regardless of the platform used.
Thread Status Functions
Thread Status/Debug Message Functions
Thread Initialization Functions
Thread Priority Functions
Thread Error Functions
Thread Parameter Functions
Thread Class ID/Object ID Functions
Overloaded Operators
vbThreadState vbThread_t::GetThreadState()
- Returns current state of the thread. This value will match one of the integer constants defined in the vbThreadState enumeration.vbThreadID vbThread_t::GetThreadID()
- Returns the platform specific thread ID.vbThreadType vbThread_t::GetThreadType()
- Returns the thread type. This value will match one of the integer constants defined in the vbThreadType enumeration.vbStackSizeType vbThread_t::GetStackSize()
- Returns the thread's stack size or zero if the default stack size was used.vbThreadAttribute * vbThread_t::GetThreadAttribute()
- Returns a pointer to the platform specific thread attribute used to initialize a thread during creation.Thread Status/Debug Message Functions:
const char * vbThread_t::ThreadExceptionMessage()
- Returns a null terminated string that can be used to log or print a thread exception.const char * vbThread_t::ThreadPriorityMessage()
- Returns a null terminated string that can be used to log or print the thread's priority.const char * vbThread_t::ThreadPriorityClassMessage()
- Returns a null terminated string that can be used to log or print the thread's priority class.const char * vbThread_t::ThreadStateMessage()
- Returns a null terminated string that can be used to log or print the thread's state.const char * vbThread_t::ThreadTypeMessage()
- Returns a null terminated string that can be used to log or print the thread type.Thread Initialization Functions:
void vbThread_t::SetThreadStackSize(unsigned ssize)
- Function used to set the thread's stack size if the default stack size is not sufficient to execute the thread's entry function. NOTE: This value must be set before the thread is created.void vbThread_t::SetThreadType(vbThreadType t)
- Function used to set the thread type prior to thread creation. This value must correspond to one of the integer constants defined in the vbThreadType enumeration. NOTE: This value must be set before the thread is created.void vbThread_t::SetThreadPriority(vbThreadPriority p)
- Function use to set a thread priority value. This value must correspond to one of the integer constants defined in the vbThreadPriority enumeration.vbThreadPriority vbThread_t::GetThreadPriority()
- Returns the current thread priority. The return value will match one of the integer constants defined in the vbThreadPriority enumeration.void vbThread_t::SetThreadPriorityClass(vbThreadPriorityClass prio_class)
- Function use to set the thread's priority class. This value must correspond to one of the integer constants defined in the vbThreadPriorityClass enumeration.vbThreadPriorityClass vbThread_t::GetThreadPriorityClass()
- Returns the current thread priority class. The return value will match one of the integer constants defined in vbThreadPriorityClassvbthread.htm - vbThreadPriorityenumeration.
vbThreadError vbThread_t::GetThreadError()
- Returns the last reported thread error. The return value will match one of the integer constants defined in vbThreadError enumeration.vbThreadExitCode vbThread_t::GetThreadExitCode()
- Returns the value returned by the thread's entry function or the value set following a vbThread::ExitThread() call.void vbThread_t::ResetThreadError()
- Function used by the application to reset a thread error.void vbThread_t::ResetThreadExitCode()
- Function used by the application to reset the thread's exit code value to zero.void * vbThread_t::GetThreadParm()
- Returns a pointer to the optional thread parameter.void vbThread_t::SetThreadParm(void *v)
- Function used by the application to set the thread's parameter prior to thread creation.vbThreadClassID vbThread_t::GetClassID()
- Returns the class ID of the thread.vbThreadObjectID vbThread_t::GetObjectID()
- Returns the object ID of the thread.void vbThread_t::SetClassID(vbThreadClassID cid)
- Function used by the application to set the thread's class ID.void vbThread_t::SetObjectID(vbThreadObjectID oid)
- Function used by the application to set the thread's object ID.int operator==(const vbThread_t &a, const vbThread_t &b)
- Friend function used to compare the thread IDs of vbThread_t "a" and vbThread_t "b". Returns true if the IDs are equal. NOTE: This function was added specifically for UNIX variants that do not use an integer type for thread IDs.int operator!=(const vbThread_t &a, const vbThread_t &b)
- Friend function used to compare the thread IDs of vbThread_t "a" and vbThread_t "b". Returns true if the IDs are not equal. NOTE: This function was added specifically for UNIX variants that do not use an integer type for thread IDs.The application is responsible for monitoring and handling any thread errors that occur following a vbThread operation. An error condition is reported to the application by any vbThread function returning a non-zero value. If any value other then 0 is returned the application must generate the appropriate exception to handle the error condition.
Thread errors are recorded by the thread API wrapper class and stored in the vbThread_t::thread_error variable. The thread error variable is accessible to the application though the appropriate vbThread_t Error Function. A thread error is a numeric value corresponding to one of the integer constants defined in the vbThreadError enumeration. The appropriate vbThread_t Message Function can be used to log or print a thread exception.
End Of Document |