24#ifndef JKQTPCONCURRENCYTOOLS_H
25#define JKQTPCONCURRENCYTOOLS_H
27#include "jkqtcommon/jkqtcommon_imexport.h"
28#include <QReadWriteLock>
30#include <QWriteLocker>
92 m_data=std::move(other.m_data);
127 inline void set(
const T& d) {
135 m_data=std::forward<T>(d);
147 m_data=std::forward<T>(d);
160 inline const T&
get()
const {
type of a lock_guard for a JKQTPSynchronized<T> for reading
Definition jkqtpconcurrencytools.h:52
ReadLocker(const JKQTPSynchronized< T > &sync, AdoptLockType) noexcept
Definition jkqtpconcurrencytools.h:55
ReadLocker(const JKQTPSynchronized< T > &sync) noexcept
Definition jkqtpconcurrencytools.h:54
~ReadLocker()
Definition jkqtpconcurrencytools.h:56
Q_DISABLE_COPY(ReadLocker) const JKQTPSynchronized< T > &m_sync
type of a lock_guard for a JKQTPSynchronized<T> for writing
Definition jkqtpconcurrencytools.h:64
WriteLocker(JKQTPSynchronized< T > &sync, AdoptLockType) noexcept
Definition jkqtpconcurrencytools.h:67
~WriteLocker()
Definition jkqtpconcurrencytools.h:68
WriteLocker(JKQTPSynchronized< T > &sync) noexcept
Definition jkqtpconcurrencytools.h:66
Q_DISABLE_COPY(WriteLocker) JKQTPSynchronized< T > &m_sync
template class that wraps any datatype and combines it with a mutex, exposes the lock()/unlock() inte...
Definition jkqtpconcurrencytools.h:40
JKQTPSynchronized(const JKQTPSynchronized< T > &other)
locks other and copies its contents to this new class
Definition jkqtpconcurrencytools.h:85
MutexType m_mutex
Definition jkqtpconcurrencytools.h:186
JKQTPSynchronized(JKQTPSynchronized< T > &&other)
locks other and moves its contents to this new class. The mutex in other is NOT moved!
Definition jkqtpconcurrencytools.h:90
void set(T &&d)
assign a value to the internal data storage, not thread-safe.
Definition jkqtpconcurrencytools.h:134
JKQTPSynchronized(const T &d)
initializing constructor, the internal data is initialized with d
Definition jkqtpconcurrencytools.h:81
const T * operator->() const
gives access to the internal data, not thread-safe.
Definition jkqtpconcurrencytools.h:167
void lockForRead() const
locks the internal mutex for writing, until unlock() is called
Definition jkqtpconcurrencytools.h:113
T * operator->()
gives access to the internal data, not thread-safe.
Definition jkqtpconcurrencytools.h:174
JKQTPSynchronized()
default constructor, the internal data is default-initialized
Definition jkqtpconcurrencytools.h:79
T m_data
Definition jkqtpconcurrencytools.h:185
const T & get() const
returns the internal data as a mutable reference, not thread-safe.
Definition jkqtpconcurrencytools.h:160
QReadWriteLock MutexType
Mutex used by this temmplate.
Definition jkqtpconcurrencytools.h:43
void lockForWrite() const
locks the internal mutex for writing, until unlock() is called
Definition jkqtpconcurrencytools.h:106
T & get()
returns the internal data as a mutable reference, not thread-safe.
Definition jkqtpconcurrencytools.h:153
T data_type
contained data type T
Definition jkqtpconcurrencytools.h:77
JKQTPSynchronized(T &&d)
initializing constructor, the internal data is initialized with d
Definition jkqtpconcurrencytools.h:83
void set_safe(T &&d)
assign a value to the internal data storage, thread-safe.
Definition jkqtpconcurrencytools.h:145
void set(const T &d)
assign a value to the internal data storage, not thread-safe.
Definition jkqtpconcurrencytools.h:127
static constexpr AdoptLockType AdoptLock
tag, which is used in ReadLocker and WriteLocker to adopt a pre-locked JKQTPSynchronized<T>
Definition jkqtpconcurrencytools.h:48
T get_safe() const
returns the value in the internal data storage, thread-safe.
Definition jkqtpconcurrencytools.h:179
void unlock() const
unlocks the internal mutex from a previous lock(), lockForWrite() or lockForRead() call
Definition jkqtpconcurrencytools.h:120
JKQTPSynchronized< T >::WriteLocker Locker
type of a lock_guard for a JKQTPSynchronized<T> for writing
Definition jkqtpconcurrencytools.h:75
void set_safe(const T &d)
assign a value to the internal data storage, thread-safe.
Definition jkqtpconcurrencytools.h:139
void lock() const
locks the internal mutex for writing, until unlock() is called
Definition jkqtpconcurrencytools.h:99
type of AdoptLock tag, which is used in ReadLocker and WriteLocker to adopt a pre-locked JKQTPSynchro...
Definition jkqtpconcurrencytools.h:46