![]() |
VR-Link API Documentation for HLA 1.3
|
a thread safe interface to a value. More...
Inheritance diagram for DtThreadSafe< T >:
Collaboration diagram for DtThreadSafe< T >:Classes | |
| class | ConstLockedProxy |
| Private class that provides a locked call to the const object. More... | |
| class | LockedProxy |
| Private class that provides a locked call to the object. More... | |
| class | SequenceLockImpl |
| Private class which implements the Sequence lock. More... | |
Public Member Functions | |
| DtThreadSafe (const T &value) | |
| DtThreadSafe () | |
| operator T () const | |
| Proxy type copy operator. | |
| LockedProxy | operator-> () |
| Proxy pointer access operator. | |
| ConstLockedProxy | operator-> () const |
| Proxy pointer access operator. | |
| DtThreadSafe< T > & | operator= (const DtThreadSafe< T > &orig) |
| Locked Copy operator,. | |
| DtThreadSafe< T > & | operator= (const T &orig) |
| Locked Copy operator, from safe value. | |
| DtScopedSequenceLock | sequenceLock () |
| Request a sequence lock, this object will maintain a lock on the object during it's life-time. | |
Protected Member Functions | |
| void | lockObject () |
| Lock the external object. | |
| void | unlockObject () |
| Unlock the external object. | |
Protected Attributes | |
| T | myValue |
| Value which is to be thread safe. | |
| DtScopedLock * | myExternalLock |
| The external lock which allows the sequence lock. | |
| DtMutex | myLockMutex |
| The mutex which is used to lock when created the external lock. | |
| DtMutex | myMutex |
| The mutex which is used to make the object thread safe. | |
Friends | |
| class | SequenceLockImpl |
a thread safe interface to a value.
Which can be shared between threads. DtThreadSafe provides a safe access to T value. T is assumed to have value semantics and is copyable. DtThreadSafe provides a locked pointer to the underlying value interface.
Example: Thread safe iteration.
DtThreadSafe<std::vector<int> > aVector; ... { DtScopedSequenceLock lock = aVector.sequenceLock(); std::vector<int>::iterator start = aVector->begin(); std::vector<int>::iterator end = aVector->end(); for(;start != end;++start) { //Now all access to iterator is considered thread safe due to *start = 0; } }
| DtThreadSafe< T >::DtThreadSafe | ( | const T & | value | ) | [explicit] |
| DtThreadSafe< T >::DtThreadSafe | ( | ) | [explicit] |
| void DtThreadSafe< T >::lockObject | ( | ) | [protected] |
Lock the external object.
| DtThreadSafe< T >::operator T | ( | ) | const |
Proxy type copy operator.
| LockedProxy DtThreadSafe< T >::operator-> | ( | ) |
Proxy pointer access operator.
The locked proxy will maintain a lock for the call (typically and the line).
| ConstLockedProxy DtThreadSafe< T >::operator-> | ( | ) | const |
Proxy pointer access operator.
The locked proxy will maintain a lock for the call (typically and the line).
| DtThreadSafe<T>& DtThreadSafe< T >::operator= | ( | const DtThreadSafe< T > & | orig | ) |
Locked Copy operator,.
| DtThreadSafe<T>& DtThreadSafe< T >::operator= | ( | const T & | orig | ) |
Locked Copy operator, from safe value.
| DtScopedSequenceLock DtThreadSafe< T >::sequenceLock | ( | ) |
Request a sequence lock, this object will maintain a lock on the object during it's life-time.
Note: this is fairly expensive and should be called sparingly.
| void DtThreadSafe< T >::unlockObject | ( | ) | [protected] |
Unlock the external object.
friend class SequenceLockImpl [friend] |
DtScopedLock* DtThreadSafe< T >::myExternalLock [protected] |
The external lock which allows the sequence lock.
This lock is not used unless a sequence is requested.
DtMutex DtThreadSafe< T >::myLockMutex [protected] |
The mutex which is used to lock when created the external lock.
DtMutex DtThreadSafe< T >::myMutex [mutable, protected] |
The mutex which is used to make the object thread safe.
T DtThreadSafe< T >::myValue [protected] |
Value which is to be thread safe.