template class that wraps any datatype and combines it with a mutex, exposes the lock()/unlock() interface, so access to the contained data can be synchronized
More...
#include <jkqtpconcurrencytools.h>
|
typedef T | data_type |
| contained data type T
|
|
typedef JKQTPSynchronized< T >::WriteLocker | Locker |
| type of a lock_guard for a JKQTPSynchronized<T> for writing
|
|
typedef QReadWriteLock | MutexType |
| Mutex used by this temmplate.
|
|
|
| JKQTPSynchronized () |
| default constructor, the internal data is default-initialized
|
|
| JKQTPSynchronized (const JKQTPSynchronized< T > &other) |
| locks other and copies its contents to this new class
|
|
| JKQTPSynchronized (const T &d) |
| initializing constructor, the internal data is initialized with d
|
|
| JKQTPSynchronized (JKQTPSynchronized< T > &&other) |
| locks other and moves its contents to this new class. The mutex in other is NOT moved!
|
|
| JKQTPSynchronized (T &&d) |
| initializing constructor, the internal data is initialized with d
|
|
T & | get () |
| returns the internal data as a mutable reference, not thread-safe.
|
|
const T & | get () const |
| returns the internal data as a mutable reference, not thread-safe.
|
|
T | get_safe () const |
| returns the value in the internal data storage, thread-safe.
|
|
void | lock () const |
| locks the internal mutex for writing, until unlock() is called
|
|
void | lockForRead () const |
| locks the internal mutex for writing, until unlock() is called
|
|
void | lockForWrite () const |
| locks the internal mutex for writing, until unlock() is called
|
|
T * | operator-> () |
| gives access to the internal data, not thread-safe.
|
|
const T * | operator-> () const |
| gives access to the internal data, not thread-safe.
|
|
void | set (const T &d) |
| assign a value to the internal data storage, not thread-safe.
|
|
void | set (T &&d) |
| assign a value to the internal data storage, not thread-safe.
|
|
void | set_safe (const T &d) |
| assign a value to the internal data storage, thread-safe.
|
|
void | set_safe (T &&d) |
| assign a value to the internal data storage, thread-safe.
|
|
void | unlock () const |
| unlocks the internal mutex from a previous lock(), lockForWrite() or lockForRead() call
|
|
template<class T>
class JKQTPSynchronized< T >
template class that wraps any datatype and combines it with a mutex, exposes the lock()/unlock() interface, so access to the contained data can be synchronized
◆ data_type
◆ Locker
type of a lock_guard for a JKQTPSynchronized<T> for writing
◆ MutexType
Mutex used by this temmplate.
◆ JKQTPSynchronized() [1/5]
default constructor, the internal data is default-initialized
◆ JKQTPSynchronized() [2/5]
initializing constructor, the internal data is initialized with d
◆ JKQTPSynchronized() [3/5]
initializing constructor, the internal data is initialized with d
◆ JKQTPSynchronized() [4/5]
locks other and copies its contents to this new class
◆ JKQTPSynchronized() [5/5]
locks other and moves its contents to this new class. The mutex in other is NOT moved!
◆ get() [1/2]
returns the internal data as a mutable reference, not thread-safe.
- Note
- You need to lock this object before calling this function.
◆ get() [2/2]
returns the internal data as a mutable reference, not thread-safe.
- Note
- You need to lock this object before calling this function.
◆ get_safe()
returns the value in the internal data storage, thread-safe.
◆ lock()
locks the internal mutex for writing, until unlock() is called
- Note
- Use WriteLocker or Locker instances to actually lock, using a RAII-idiom, as this is safer than doing this by hand!
◆ lockForRead()
locks the internal mutex for writing, until unlock() is called
- Note
- Use WriteLocker or Locker instances to actually lock, using a RAII-idiom, as this is safer than doing this by hand!
◆ lockForWrite()
locks the internal mutex for writing, until unlock() is called
- Note
- Use WriteLocker or Locker instances to actually lock, using a RAII-idiom, as this is safer than doing this by hand!
◆ operator->() [1/2]
gives access to the internal data, not thread-safe.
- Note
- You need to lock this object before calling this function.
◆ operator->() [2/2]
gives access to the internal data, not thread-safe.
- Note
- You need to lock this object before calling this function.
◆ set() [1/2]
assign a value to the internal data storage, not thread-safe.
- Note
- You need to lock this object before calling this function.
◆ set() [2/2]
assign a value to the internal data storage, not thread-safe.
- Note
- You need to lock this object before calling this function.
◆ set_safe() [1/2]
assign a value to the internal data storage, thread-safe.
◆ set_safe() [2/2]
assign a value to the internal data storage, thread-safe.
◆ unlock()
unlocks the internal mutex from a previous lock(), lockForWrite() or lockForRead() call
- Note
- Use Locker instances to actually lock, using a RAII-idiom, as this is safer than doing this by hand!
◆ AdoptLock
◆ m_data
◆ m_mutex
The documentation for this class was generated from the following file: