SourcePro® API Reference Guide

 
List of all members | Public Member Functions | Static Public Member Functions | Protected Member Functions | Related Functions
RWThreadSelf Class Reference

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

#include <rw/thread/RWThreadSelf.h>

Inheritance diagram for RWThreadSelf:
RWRunnableSelf RWRunnableHandle RWHandleBase

Public Member Functions

 RWThreadSelf ()
 
 RWThreadSelf (RWStaticCtor)
 
 RWThreadSelf (const RWThreadSelf &second)
 
 ~RWThreadSelf ()
 
bool canGetPriority () const
 
bool canGetProcessScopePriority () const
 
bool canGetSchedulingPolicy () const
 
bool canGetSystemScopePriority () const
 
bool canGetTimeSliceQuantum () const
 
bool canSetPriority () const
 
bool canSetProcessScopePriority () const
 
bool canSetSchedulingPolicy (RWSchedulingPolicy policy) const
 
bool canSetSystemScopePriority () const
 
bool canSetTimeSliceQuantum () const
 
RWThreadAttribute getActiveAttribute () const
 
RWThreadAttribute getAttribute () 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
 
RWPriority getPriority () const
 
RWPriority getProcessScopePriority () const
 
RWThread getRWThread () const
 
RWSchedulingPolicy getSchedulingPolicy () const
 
RWPriority getSystemScopePriority () const
 
unsigned long getTimeSliceQuantum () const
 
RWThreadSelfoperator= (const RWThreadSelf &second)
 
void setAttribute (const RWThreadAttribute &second)
 
void setPriority (RWPriority priority)
 
void setProcessScopePriority (RWPriority priority)
 
void setSchedulingPolicy (RWSchedulingPolicy policy)
 
void setSystemScopePriority (RWPriority priority)
 
void setTimeSliceQuantum (unsigned long milliseconds)
 
unsigned suspend ()
 
- Public Member Functions inherited from RWRunnableSelf
 RWRunnableSelf ()
 
 RWRunnableSelf (RWStaticCtor)
 
 RWRunnableSelf (const RWRunnableSelf &second)
 
 ~RWRunnableSelf ()
 
RWRunnableSelf getNestedRunnable () const
 
RWRunnable getRWRunnable () const
 
void interrupt ()
 
RWRunnableSelfoperator= (const RWRunnableSelf &second)
 
void serviceCancellation ()
 
bool serviceInterrupt ()
 
void sleep (unsigned long milliseconds)
 
void yield ()
 
- Public Member Functions inherited from RWRunnableHandle
void addCallback (const RWTFunctor< void(const RWRunnable &, RWExecutionState)> &functor, unsigned long stateMask, RWCallbackScope scope=RW_CALL_REPEATEDLY)
 
RWCompletionState getCompletionState () const
 
RWExecutionState getExecutionState () const
 
bool isInterruptRequested () const
 
bool isSelf () const
 
bool isSelf (const RWThreadId &id) const
 
void removeCallback (const RWTFunctor< void(const RWRunnable &, RWExecutionState)> &functor)
 
RWThreadId threadId () const
 
- Public Member Functions inherited from RWHandleBase
bool isValid (void) const
 
bool operator!= (const RWHandleBase &second) const
 
bool operator< (const RWHandleBase &second) const
 
bool operator== (const RWHandleBase &second) const
 

Static Public Member Functions

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

Protected Member Functions

 RWThreadSelf (const RWThread &second)
 
- Protected Member Functions inherited from RWRunnableSelf
 RWRunnableSelf (const RWRunnable &second)
 
- Protected Member Functions inherited from RWRunnableHandle
 RWRunnableHandle ()
 
 RWRunnableHandle (RWStaticCtor)
 
 RWRunnableHandle (RWRunnableImp *runnableImpP)
 
 RWRunnableHandle (const RWRunnableHandle &second)
 
 ~RWRunnableHandle ()
 
RWRunnableHandleoperator= (const RWRunnableHandle &second)
 
- Protected Member Functions inherited from RWHandleBase
 RWHandleBase (void)
 
 RWHandleBase (RWStaticCtor)
 
 RWHandleBase (RWBodyBase *body)
 
 RWHandleBase (const RWHandleBase &second)
 
 ~RWHandleBase (void)
 
RWBodyBasebody (void) const
 
RWHandleBaseoperator= (const RWHandleBase &second)
 

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

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.

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.

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.

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.

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.

static bool RWThreadSelf::canSuspendResume ( )
static

Returns true if the current environment supports the suspend() and RWThread::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 RWThread::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 RWThread::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 RWThread::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 RWThread::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

Copyright © 2022 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved.