SourcePro® 2023.1 |
SourcePro® API Reference Guide |
Provides thread-local storage with simple by-value semantics. More...
#include <rw/thread/RWTThreadLocal.h>
Public Member Functions | |
RWTThreadLocal (RWStaticCtor) | |
RWTThreadLocal () | |
~RWTThreadLocal () | |
Type & | getValue () const |
bool | isSet () const |
operator Type () const | |
RWTThreadLocal< Type > & | operator= (const Type &value) |
bool | reset (void) |
void | setValue (const Type &value) |
Private Member Functions | |
RWTThreadLocal (const RWTThreadLocal &second) | |
RWTThreadLocal & | operator= (const RWTThreadLocal &second) |
Additional Inherited Members | |
Protected Types inherited from RWTMonitor< RWMutexLock > | |
typedef RWTLockGuard< RWTMonitor< RWMutexLock > > | LockGuard |
typedef RWTTryLockGuard< RWTMonitor< RWMutexLock > > | TryLockGuard |
typedef RWTUnlockGuard< RWTMonitor< RWMutexLock > > | UnlockGuard |
Protected Member Functions inherited from RWTMonitor< RWMutexLock > | |
RWTMonitor () | |
RWTMonitor (RWStaticCtor) | |
RWTMonitor (const RWTMonitor< RWMutexLock > &second) | |
~RWTMonitor () | |
void | acquire () |
bool | isAcquired () const |
RWTMonitor< RWMutexLock > & | monitor () const |
RWMutexLock & | mutex () |
RWTMonitor< RWMutexLock > & | operator= (const RWTMonitor< RWMutexLock > &) |
void | release () |
bool | tryAcquire () |
The RWTThreadLocal class provides thread-local storage with simple by-value semantics. An RWTThreadLocal instance may be shared between multiple threads. Doing so creates one instance of typed data per thread. Each thread accesses its own private instance of the typed data whenever it uses the shared RWTThreadLocal instance.
RWTThreadLocal< Type >::RWTThreadLocal | ( | RWStaticCtor | ) |
Constructs an RWTThreadLocal instance, which is initialized when first used, unlike an instance created by the default constructor, which is initialized when constructed.
RWTThreadLocal< Type >::RWTThreadLocal | ( | ) |
Constructs and initializes a thread-local storage object. The first time a thread accesses this object, a new instance of Type
is created specifically for that thread. Each subsequent access by the same thread references the same Type
instance.
RWTThreadLocal< Type >::~RWTThreadLocal | ( | ) |
Destroys the thread-local storage object. Since thread-local storage objects are often declared at global scope, they necessarily are destroyed during the program termination process. Any threads that may still be running during program termination must guard against trying to access these storage objects.
|
private |
Copy construction prohibited.
Type& RWTThreadLocal< Type >::getValue | ( | ) | const |
Retrieves a reference to the current value of this variable.
|
inline |
Returns true
if this variable has been set in the current thread, otherwise returns false
.
|
inline |
Retrieves and returns the value previously stored by the current thread.
|
inline |
Assigns a Type
value to self. The value assigned is available only to the current thread. Access of self by other threads manipulate the values stored specifically for those threads.
|
private |
Assignment prohibited.
bool RWTThreadLocal< Type >::reset | ( | void | ) |
Resets the value of this object.
void RWTThreadLocal< Type >::setValue | ( | const Type & | value | ) |
Sets the value of this object.
Copyright © 2023 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved. |