#include <PhxAccessors.h>
Inheritance diagram for Phx::WriteLockedAccessor< T >:

Public Member Functions | |
| WriteLockedAccessor (const T &data, ReadWriteLock *lock) | |
| Constructs a WriteLockedAccessor that offers access to its data while a given lock is held. | |
| WriteLockedAccessor (const T &data, WriteLockHolder *lockHolder) | |
| Constructs a locked accessor that offers read only access to its data while holding the lock already acquired via a WriteLockHolder. | |
| T & | data () |
| Returns the protected data to the client. | |
A WriteLockedAccessor is an object that contains a WriteLockHolder and a copy of some data protected by that lock. For as long as this object is in existance, the data may be safely accessed under the protection provided by the lock. When this object is destructed, the lock holder is destroyed and the lock released.
The client can access the data via the data() method.
The template parameter T is the data type that is held by this object. The lock is interpreted as protecting the contents of the T object that is held. It does NOT protect the reference to the T itself. That is, the lock belongs to the T, and not to the object that contains T.
The template parameter T must be a copy-constructable type.
|
||||||||||||||||
|
Constructs a WriteLockedAccessor that offers access to its data while a given lock is held.
|
|
||||||||||||||||
|
Constructs a locked accessor that offers read only access to its data while holding the lock already acquired via a WriteLockHolder.
|
|
|||||||||
|
Returns the protected data to the client. Note that this returns a non-const reference and thus does not enforce the read-only nature of read access. The primary function of this object is to hold the read lock and it will not impose read only access on the data on its own. To get this behavior, simply change the template parameter to "const T" instead of "T". For instance, to only give const access to the client, declare your accessor as WriteLockedAccessor<const myobject=""> rather than WriteLockedAccessor<MyObject>.
|
1.4.2