rwlogo
SourcePro C++ 12.0

SourcePro® C++ API Reference Guide



   SourcePro C++
Documentation Home

RWThreadSelf Class Reference
[Threading]

Handle class for a threaded runnable object. More...

#include <rw/thread/RWThreadSelf.h>

Inheritance diagram for RWThreadSelf:
RWRunnableSelf RWRunnableHandle RWHandleBase

List of all members.

Public Member Functions

 RWThreadSelf ()
 RWThreadSelf (RWStaticCtor)
 RWThreadSelf (const RWThreadSelf &second)
 ~RWThreadSelf ()
RWThreadSelfoperator= (const RWThreadSelf &second)
RWThread getRWThread () const
RWThreadAttribute getAttribute () const
void setAttribute (const RWThreadAttribute &second)
RWThreadAttribute getActiveAttribute () const
RWPriority getMaxPriority () const
RWPriority getMaxProcessScopePriority () const
RWPriority getMaxSystemScopePriority () const
unsigned long getMaxTimeSliceQuantum () const
RWPriority getMinPriority () const
RWPriority getMinProcessScopePriority () const
RWPriority getMinSystemScopePriority () const
unsigned long getMinTimeSliceQuantum () const
bool canGetPriority () const
bool canGetProcessScopePriority () const
bool canGetSchedulingPolicy () const
bool canGetSystemScopePriority () const
bool canGetTimeSliceQuantum () const
RWPriority getPriority () const
RWPriority getProcessScopePriority () const
RWSchedulingPolicy getSchedulingPolicy () const
RWPriority getSystemScopePriority () const
unsigned long getTimeSliceQuantum () const
bool canSetPriority () const
bool canSetProcessScopePriority () const
bool canSetSchedulingPolicy (RWSchedulingPolicy policy) const
bool canSetSystemScopePriority () const
bool canSetTimeSliceQuantum () const
void setPriority (RWPriority priority)
void setProcessScopePriority (RWPriority priority)
void setSchedulingPolicy (RWSchedulingPolicy policy)
void setSystemScopePriority (RWPriority priority)
void setTimeSliceQuantum (unsigned long milliseconds)
unsigned suspend ()

Static Public Member Functions

static bool canGetMaxThreads ()
static size_t getMaxThreads ()
static bool canSuspendResume ()

Protected Member Functions

 RWThreadSelf (const RWThread &second)
RWThreadImp & body (void) const

Related Functions

(Note that these are not member functions.)



RWThreadSelf rwThread ()

Detailed Description

The RWThreadSelf class is a handle class for a threaded runnable object, providing an interface for threads that execute inside the threaded runnable.

A threaded runnable object provides the basic mechanisms used to create, control, and monitor the threads of execution within your application. Threaded runnables create their own thread to perform some task or activity.

Each threaded runnable object is reference-counted; a threaded runnable body instance keeps a count of the number of handles that currently reference it. A runnable object is deleted when the last handle that references the body is deleted.

A threaded runnable handle class instance may be empty. Any attempt to use an empty handle to access a threaded runnable produces an RWTHRInvalidPointer exception.

The public interface for a threaded runnable is provided by its handle classes. Many of the public functions in a handle simply forward control to a corresponding protected function in the body class.

The RWThreadSelf class provides an interface for the thread executing inside of a threaded runnable. It defines the member functions that may only be executed only by the internal thread. Threads executing outside of a threaded runnable should access the runnable using the RWThread handle class. Functions available from either inside or outside of a threaded runnable are defined in both handle classes.

To retrieve an RWThreadSelf handle instance for the current threaded runnable, use the rwThread() function. You may also convert an RWThread handle to an RWThreadSelf handle by calling the RWThread::getRWThreadSelf() member, but any attempt to violate the thread access restrictions imposed by the separate interfaces generally results in an RWTHRIllegalAccess exception.

See also:
RWThread, RWRunnableSelf, RWRunnableHandle, RWThreadAttribute

Constructor & Destructor Documentation

RWThreadSelf::RWThreadSelf (  )  [inline]

Creates an empty RWThreadSelf handle. Until this object is bound to a threaded runnable, its isValid() member returns false.

RWThreadSelf::RWThreadSelf ( RWStaticCtor   )  [inline]

Constructs a global static handle instance, that may be assigned to before construction. The static constructor does not change the instance state.

RWThreadSelf::RWThreadSelf ( const RWThreadSelf second  )  [inline]

Copy constructor. Creates an RWThreadSelf object associated with the same thread (if any) associated with second.

RWThreadSelf::~RWThreadSelf (  )  [inline]

Destructor.

RWThreadSelf::RWThreadSelf ( const RWThread second  )  [protected]

Conversion constructor.


Member Function Documentation

RWThreadImp& RWThreadSelf::body ( void   )  const [protected]

Gets a reference for the body instance, if any.

Exceptions:
RWTHRInvalidPointer Thrown if this handle is not attached to a body.

Reimplemented from RWRunnableHandle.

static bool RWThreadSelf::canGetMaxThreads (  )  [static]

Returns true if the getMaxThreads() function is supported in the current environment, otherwise false.

bool RWThreadSelf::canGetPriority (  )  const

Each "canGetXxx" function returns true if the corresponding attribute is supported in the current environment and if the corresponding "getXxx" function can return a legal value under the current circumstances. For example, canGetPriority() returns true only if RW_THR_HAS_PRIORITY is defined and calling related functions such as getPriority() and getMaxPriority() can return a legal value under the current circumstances.

Possible exceptions include RWTHRInvalidPointer and RWTHRInternalError.

bool RWThreadSelf::canGetProcessScopePriority (  )  const

Each "canGetXxx" function returns true if the corresponding attribute is supported in the current environment and if the corresponding "getXxx" function can return a legal value under the current circumstances. For example, canGetPriority() returns true only if RW_THR_HAS_PRIORITY is defined and calling related functions such as getPriority() and getMaxPriority() can return a legal value under the current circumstances.

Possible exceptions include RWTHRInvalidPointer and RWTHRInternalError.

bool RWThreadSelf::canGetSchedulingPolicy (  )  const

Each "canGetXxx" function returns true if the corresponding attribute is supported in the current environment and if the corresponding "getXxx" function can return a legal value under the current circumstances. For example, canGetPriority() returns true only if RW_THR_HAS_PRIORITY is defined and calling related functions such as getPriority() and getMaxPriority() can return a legal value under the current circumstances.

Possible exceptions include RWTHRInvalidPointer and RWTHRInternalError.

bool RWThreadSelf::canGetSystemScopePriority (  )  const

Each "canGetXxx" function returns true if the corresponding attribute is supported in the current environment and if the corresponding "getXxx" function can return a legal value under the current circumstances. For example, canGetPriority() returns true only if RW_THR_HAS_PRIORITY is defined and calling related functions such as getPriority() and getMaxPriority() can return a legal value under the current circumstances.

Possible exceptions include RWTHRInvalidPointer and RWTHRInternalError.

bool RWThreadSelf::canGetTimeSliceQuantum (  )  const

Each "canGetXxx" function returns true if the corresponding attribute is supported in the current environment and if the corresponding "getXxx" function can return a legal value under the current circumstances. For example, canGetPriority() returns true only if RW_THR_HAS_PRIORITY is defined and calling related functions such as getPriority() and getMaxPriority() can return a legal value under the current circumstances.

Possible exceptions include RWTHRInvalidPointer and RWTHRInternalError.

bool RWThreadSelf::canSetPriority (  )  const

Each "canSetXxx()" function returns true if the corresponding attribute is supported in the current environment and if the corresponding "setXxx()" function is callable under the current circumstances. For example, canSetPriority() returns true only if RW_THR_HAS_PRIORITY is defined and calling setPriority() is supported under the current options. In addition, the function returns true only if both the calling thread and process have sufficient privileges to perform the requested operation.

Possible exceptions include RWTHRInvalidPointer and RWTHRInternalError. In addition, canSetSchedulingPolicy() can throw RWTHRBoundsError.

bool RWThreadSelf::canSetProcessScopePriority (  )  const

Each "canSetXxx()" function returns true if the corresponding attribute is supported in the current environment and if the corresponding "setXxx()" function is callable under the current circumstances. For example, canSetPriority() returns true only if RW_THR_HAS_PRIORITY is defined and calling setPriority() is supported under the current options. In addition, the function returns true only if both the calling thread and process have sufficient privileges to perform the requested operation.

Possible exceptions include RWTHRInvalidPointer and RWTHRInternalError. In addition, canSetSchedulingPolicy() can throw RWTHRBoundsError.

bool RWThreadSelf::canSetSchedulingPolicy ( RWSchedulingPolicy  policy  )  const

Each "canSetXxx()" function returns true if the corresponding attribute is supported in the current environment and if the corresponding "setXxx()" function is callable under the current circumstances. For example, canSetPriority() returns true only if RW_THR_HAS_PRIORITY is defined and calling setPriority() is supported under the current options. In addition, the function returns true only if both the calling thread and process have sufficient privileges to perform the requested operation.

Possible exceptions include RWTHRInvalidPointer and RWTHRInternalError. In addition, canSetSchedulingPolicy() can throw RWTHRBoundsError.

bool RWThreadSelf::canSetSystemScopePriority (  )  const

Each "canSetXxx()" function returns true if the corresponding attribute is supported in the current environment and if the corresponding "setXxx()" function is callable under the current circumstances. For example, canSetPriority() returns true only if RW_THR_HAS_PRIORITY is defined and calling setPriority() is supported under the current options. In addition, the function returns true only if both the calling thread and process have sufficient privileges to perform the requested operation.

Possible exceptions include RWTHRInvalidPointer and RWTHRInternalError. In addition, canSetSchedulingPolicy() can throw RWTHRBoundsError.

bool RWThreadSelf::canSetTimeSliceQuantum (  )  const

Each "canSetXxx()" function returns true if the corresponding attribute is supported in the current environment and if the corresponding "setXxx()" function is callable under the current circumstances. For example, canSetPriority() returns true only if RW_THR_HAS_PRIORITY is defined and calling setPriority() is supported under the current options. In addition, the function returns true only if both the calling thread and process have sufficient privileges to perform the requested operation.

Possible exceptions include RWTHRInvalidPointer and RWTHRInternalError. In addition, canSetSchedulingPolicy() can throw RWTHRBoundsError.

static bool RWThreadSelf::canSuspendResume (  )  [static]

Returns true if the current environment supports the suspend() and resume() members functions, otherwise false.

RWThreadAttribute RWThreadSelf::getActiveAttribute (  )  const

Returns a handle to the thread attribute instance used to initialize the most recently created thread. If a thread has not yet been created, this function simply returns a copy of a default thread attribute instance.

Possible exceptions include RWTHRInvalidPointer and RWTHRInternalError.

RWThreadAttribute RWThreadSelf::getAttribute (  )  const

Returns a handle to the thread attribute object used to initialize any threads created by future calls to start(). Use getActiveAttribute() to get a copy of the attribute instance actually used to initialize the most recently started thread.

Possible exceptions include RWTHRInvalidPointer and RWTHRInternalError.

RWPriority RWThreadSelf::getMaxPriority (  )  const

Returns the maximum priority value that may be specified for this thread. At runtime, use canGetPriority() to determine the availability of this feature. At compile time, check to see if RW_THR_HAS_PRIORITY is defined.

Possible exceptions include RWTHRInvalidPointer, RWTHROperationNotSupported, RWTHROperationNotAvailable, RWTHRThreadNotActive, and RWTHRInternalError.

RWPriority RWThreadSelf::getMaxProcessScopePriority (  )  const

Returns the maximum process-scope priority value that may be specified for this thread. At runtime, use canGetProcessScopePriority() to determine the availability of this feature. At compile time, check to see if RW_THR_HAS_PROCESS_SCOPE_PRIORITY is defined.

Possible exceptions include RWTHRInvalidPointer, RWTHROperationNotSupported, RWTHROperationNotAvailable, RWTHRThreadNotActive, and RWTHRInternalError.

RWPriority RWThreadSelf::getMaxSystemScopePriority (  )  const

Returns the maximum system-scope priority value that may be specified for this thread. At runtime, use canGetSystemScopePriority() to determine the availability of this feature. At compile time, check to see if RW_THR_HAS_SYSTEM_SCOPE_PRIORITY is defined.

Possible exceptions include RWTHRInvalidPointer, RWTHROperationNotSupported, RWTHROperationNotAvailable, RWTHRThreadNotActive, and RWTHRInternalError.

static size_t RWThreadSelf::getMaxThreads (  )  [static]

Returns the maximum number of threads that may be created in this environment. This function is not supported in all environments. At runtime, use canGetMaxThreads() to determine whether this feature is available. At compile time, check to see if RW_THR_HAS_MAX_THREADS is defined.

Possible exceptions include RWTHROperationNotSupported.

unsigned long RWThreadSelf::getMaxTimeSliceQuantum (  )  const

Returns the maximum time-slice quantum value that may be specified for this thread. At runtime, use canGetTimeSliceQuantum() to determine the availability of this feature. At compile time, check to see if RW_THR_HAS_TIME_SLICE_QUANTUM is defined.

Possible exceptions include RWTHRInvalidPointer, RWTHROperationNotSupported, RWTHROperationNotAvailable, RWTHRThreadNotActive, and RWTHRInternalError.

RWPriority RWThreadSelf::getMinPriority (  )  const

Returns the minimum priority value that may be specified for this thread. At runtime, use canGetPriority() to determine the availability of this feature. At compile time, check to see if RW_THR_HAS_PRIORITY is defined.

Possible exceptions include RWTHRInvalidPointer, RWTHROperationNotSupported, RWTHROperationNotAvailable, RWTHRThreadNotActive, and RWTHRInternalError.

RWPriority RWThreadSelf::getMinProcessScopePriority (  )  const

Returns the minimum process-scope priority value that may be specified for this thread. At runtime, use canGetProcessScopePriority() to determine the availability of this feature. At compile time, check to see if RW_THR_HAS_PROCESS_SCOPE_PRIORITY is defined.

Possible exceptions include RWTHRInvalidPointer, RWTHROperationNotSupported, RWTHROperationNotAvailable, RWTHRThreadNotActive, and RWTHRInternalError.

RWPriority RWThreadSelf::getMinSystemScopePriority (  )  const

Returns the minimum system-scope priority value that may be specified for this thread. At runtime, use canGetSystemScopePriority() to determine the availability of this feature. At compile time, check to see if RW_THR_HAS_SYSTEM_SCOPE_PRIORITY is defined.

Possible exceptions include RWTHRInvalidPointer, RWTHROperationNotSupported, RWTHROperationNotAvailable, RWTHRThreadNotActive, and RWTHRInternalError. and RWTHRInternalError.

unsigned long RWThreadSelf::getMinTimeSliceQuantum (  )  const

Returns the minimum time-slice quantum value that may be specified for this thread. At runtime, use canGetTimeSliceQuantum() to determine the availability of this feature. At compile time, check to see if RW_THR_HAS_TIME_SLICE_QUANTUM is defined.

Possible exceptions include RWTHRInvalidPointer, RWTHROperationNotSupported, RWTHROperationNotAvailable, RWTHRThreadNotActive, and RWTHRInternalError.

RWPriority RWThreadSelf::getPriority (  )  const

Returns the current priority for the active thread associated with self. At runtime, use canGetPriority() to determine the availability of this feature. At compile time, check to see if RW_THR_HAS_PRIORITY is defined.

Possible exceptions include RWTHRInvalidPointer, RWTHROperationNotSupported, RWTHRThreadNotActive, and RWTHRInternalError.

RWPriority RWThreadSelf::getProcessScopePriority (  )  const

Returns the current process-scope priority for the active thread associated with self. At runtime, use canGetProcessScopePriority() to determine the availability of this feature. At compile time, check to see if RW_THR_HAS_PROCESS_SCOPE_PRIORITY is defined.

Possible exceptions include RWTHRInvalidPointer, RWTHROperationNotSupported, RWTHROperationNotAvailable, RWTHRThreadNotActive, and RWTHRInternalError.

RWThread RWThreadSelf::getRWThread (  )  const

Returns an external thread interface associated with the same thread, if any, associated with self.

RWSchedulingPolicy RWThreadSelf::getSchedulingPolicy (  )  const

Returns the current scheduling policy for the active thread associated with self. At runtime, use canGetSchedulingPolicy() to determine the availability of this feature. At compile time, check to see if RW_THR_HAS_SCHEDULING_POLICY is defined.

Possible exceptions include RWTHRInvalidPointer, RWTHROperationNotSupported, RWTHRThreadNotActive, and RWTHRInternalError.

RWPriority RWThreadSelf::getSystemScopePriority (  )  const

Returns the current system-scope priority for the active thread associated with self. At runtime, use canGetSystemScopePriority() to determine the availability of this feature. At compile time, check to see if RW_THR_HAS_SYSTEM_SCOPE_PRIORITY is defined.

Possible exceptions include RWTHRInvalidPointer, RWTHROperationNotSupported, RWTHROperationNotAvailable, RWTHRThreadNotActive, and RWTHRInternalError.

unsigned long RWThreadSelf::getTimeSliceQuantum (  )  const

Returns the current time-slice quantum value for the active thread associated with self. At runtime, use canGetTimeSliceQuantum() to determine the availability of this feature. At compile time, check to see if RW_THR_HAS_TIME_SLICE_QUANTUM is defined.

Possible exceptions include RWTHRInvalidPointer, RWTHROperationNotSupported, RWTHROperationNotAvailable, RWTHRThreadNotActive, and RWTHRInternalError.

RWThreadSelf & RWThreadSelf::operator= ( const RWThreadSelf second  )  [inline]

Assignment operator. Binds the handle to the same threaded runnable, if any, pointed-to by second.

void RWThreadSelf::setAttribute ( const RWThreadAttribute second  ) 

Replaces the thread attribute instance used to initialize any threads created by future calls to start(). Changing a thread's attribute object after the thread has been started does not affect its current thread.

Possible exceptions include RWTHRInvalidPointer and RWTHRInternalError.

void RWThreadSelf::setPriority ( RWPriority  priority  ) 

Changes the priority of thread associated with self. At runtime, use canSetPriority() to determine the availability of this feature. At compile time, check to see if RW_THR_HAS_PRIORITY is defined.

Possible exceptions include RWTHRInvalidPointer, RWTHROperationNotSupported, RWTHROperationNotAvailable, RWTHRThreadNotActive, RWTHRBoundsError, RWTHRResourceLimit, and RWTHRInternalError.

void RWThreadSelf::setProcessScopePriority ( RWPriority  priority  ) 

Changes the process-scope priority of the thread associated with self. At runtime, use canSetProcessScopePriority() to determine the availability of this feature. At compile time, check to see if RW_THR_HAS_PROCESS_SCOPE_PRIORITY is defined.

Possible exceptions include RWTHRInvalidPointer, RWTHROperationNotSupported, RWTHROperationNotAvailable, RWTHRThreadNotActive, RWTHRBoundsError, RWTHRResourceLimit, and RWTHRInternalError.

void RWThreadSelf::setSchedulingPolicy ( RWSchedulingPolicy  policy  ) 

Changes the scheduling policy of the thread associated with self. At runtime, use canSetSchedulingPolicy(policy) to determine the availability of this feature. At compile time check to see if RW_THR_HAS_SCHEDULING_POLICY is defined.

Possible exceptions include RWTHRInvalidPointer, RWTHROperationNotSupported, RWTHROperationNotAvailable, RWTHRThreadNotActive, RWTHRBoundsError, RWTHRResourceLimit, and RWTHRInternalError.

void RWThreadSelf::setSystemScopePriority ( RWPriority  priority  ) 

Changes the system-scope priority of the thread associated with self. At runtime, use canSetSystemScopePriority() to determine the availability of this feature. At compile time, check to see if RW_THR_HAS_SYSTEM_SCOPE_PRIORITY is defined.

Possible exceptions include RWTHRInvalidPointer, RWTHROperationNotSupported, RWTHROperationNotAvailable, RWTHRThreadNotActive, RWTHRBoundsError, RWTHRResourceLimit, and RWTHRInternalError.

void RWThreadSelf::setTimeSliceQuantum ( unsigned long  milliseconds  ) 

Changes the time-slice quantum value of the thread associated with self. At runtime, use canSetTimeSliceQuantum() to determine the availability of this feature. At compile time, check to see if RW_THR_HAS_TIME_SLICE_QUANTUM is defined.

Possible exceptions include RWTHRInvalidPointer, RWTHROperationNotSupported, RWTHROperationNotAvailable, RWTHRThreadNotActive, RWTHRBoundsError, RWTHRResourceLimit, and RWTHRInternalError.

unsigned RWThreadSelf::suspend (  ) 

Suspends the execution of the thread associated with self until a matching resume() operation is performed.

Warning:
Use of this function may produce unexpected deadlock (see the Threads User's Guide for more information). For deadlock-safe suspension, use requestInterrupt() and serviceInterrupt() instead.

At runtime, use canSuspendResume() to determine the availability of this feature. At compile time, check to see if RW_THR_HAS_SUSPEND_RESUME is defined.

Possible exceptions include RWTHRInvalidPointer, RWTHROperationNotSupported, RWTHRThreadNotActive, and RWTHRInternalError.


Friends And Related Function Documentation

RWThreadSelf rwThread (  )  [related]

This function returns the internal thread handle, of type RWThreadSelf, associated with the current thread (if any). It will return an empty RWThreadSelf handle if the current thread was not started by a Threads Module threaded runnable object. The returned thread handle should be tested for validity, by using the isValid() member, if the code calling the function does not know that it is running in a thread started by a Threads Module thread object.

See also:
RWThreadSelf
 All Classes Functions Variables Typedefs Enumerations Enumerator Friends

© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.