libjmmcg
release_579_6_g8cffd
A C++ library containing an eclectic mix of useful, advanced components.
|
An adaptor to add thread-safety assistance, specifically for queues. More...
#include <thread_safe_adaptors.hpp>
Inherits QT.
Public Types | |
typedef QT | container_type |
The queue to be adapted, usually std::list or std::queue. More... | |
typedef Sig | have_work_type |
Used to enable functionality to atomically signal if the container contains work or not. More... | |
typedef M | atomic_t |
The underlying lock object to use. More... | |
typedef WL | write_lock_type |
The type of write-lock to use. This allows the possibility of using a read-write lock. More... | |
typedef atomic_t::read_lock_type | read_lock_type |
The type of read lock to use, by default the write lock. This allows the possibility of using a read-write lock. More... | |
typedef MLk | lock_all_type |
The multi-lock type to use to ensured that operations on combined queues are thread-safe. Note that locking them in any order reduces the likelihood of deadlock at the cost of performance. More... | |
typedef write_lock_type::lock_traits | lock_traits |
template<class... T> | |
using | scoped_lock = typename lock_traits::template scoped_lock< T... > |
typedef api_threading_traits< lock_traits::api_type, typename lock_traits::model_type > | thread_traits |
typedef container_type::reference | reference |
typedef container_type::const_reference | const_reference |
typedef container_type::size_type | size_type |
typedef container_type::value_type | value_type |
typedef ValRet | value_ret_type |
The type to return when removing items from the queue. More... | |
typedef lock_traits::exception_type | exception_type |
Public Attributes | |
have_work_type | have_work |
A flag to atomically signal if the container contains work or not, and how much work. More... | |
Static Public Attributes | |
static constexpr size_type | serialise_size =2 |
The size of the queue, below which the push & pop operations serialise. More... | |
static constexpr generic_traits::memory_access_modes | memory_access_mode |
Protected Member Functions | |
value_type &__fastcall | back_nolk () noexcept(true) FORCE_INLINE |
virtual value_ret_type __fastcall | pop_front_nochk_nolk () noexcept(false) FORCE_INLINE |
An adaptor to add thread-safety assistance, specifically for queues.
Note that this adaptor relies on the standardised behaviour of a sequence (or an adaptor thereof) with respect to invalidating iterators when items are added to or removed from removed from the container. Basically only std::list is guaranteed to satisfy these requirements, but std::queue often does, but that is implementation-dependent. This queue operates two locks, a pop & a push lock, that operate independently as long as the queue is large enough. The operations push() and push_back() have a push lock and are thus serialised. The operations pop() and pop_front() have a pop lock and are thus serialised. When the queue is too short, these pairs of operations are also mutually serialised. By default the adapted queue does not use a read-write lock. The iterators are not exposed to assist with writing thread-safe code. Note that if the read_lock_type and write_lock_types are the same, i.e. an exclusive lock were used, then the adaptor will exhibit EREW semantics. If a read-writer lock is used for them, then it will exhibit CREW semantics.
Definition at line 448 of file thread_safe_adaptors.hpp.
typedef M jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::funky_queue< QT, M, WL, Sig, ValRet, MLk >::atomic_t |
The underlying lock object to use.
Definition at line 452 of file thread_safe_adaptors.hpp.
typedef container_type::const_reference jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::funky_queue< QT, M, WL, Sig, ValRet, MLk >::const_reference |
Definition at line 461 of file thread_safe_adaptors.hpp.
typedef QT jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::funky_queue< QT, M, WL, Sig, ValRet, MLk >::container_type |
The queue to be adapted, usually std::list or std::queue.
Definition at line 450 of file thread_safe_adaptors.hpp.
typedef lock_traits::exception_type jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::funky_queue< QT, M, WL, Sig, ValRet, MLk >::exception_type |
Definition at line 465 of file thread_safe_adaptors.hpp.
typedef Sig jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::funky_queue< QT, M, WL, Sig, ValRet, MLk >::have_work_type |
Used to enable functionality to atomically signal if the container contains work or not.
Definition at line 451 of file thread_safe_adaptors.hpp.
typedef MLk jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::funky_queue< QT, M, WL, Sig, ValRet, MLk >::lock_all_type |
The multi-lock type to use to ensured that operations on combined queues are thread-safe. Note that locking them in any order reduces the likelihood of deadlock at the cost of performance.
Definition at line 455 of file thread_safe_adaptors.hpp.
typedef write_lock_type::lock_traits jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::funky_queue< QT, M, WL, Sig, ValRet, MLk >::lock_traits |
Definition at line 456 of file thread_safe_adaptors.hpp.
typedef atomic_t::read_lock_type jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::funky_queue< QT, M, WL, Sig, ValRet, MLk >::read_lock_type |
The type of read lock to use, by default the write lock. This allows the possibility of using a read-write lock.
Definition at line 454 of file thread_safe_adaptors.hpp.
typedef container_type::reference jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::funky_queue< QT, M, WL, Sig, ValRet, MLk >::reference |
Definition at line 460 of file thread_safe_adaptors.hpp.
using jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::funky_queue< QT, M, WL, Sig, ValRet, MLk >::scoped_lock = typename lock_traits::template scoped_lock<T...> |
Definition at line 458 of file thread_safe_adaptors.hpp.
typedef container_type::size_type jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::funky_queue< QT, M, WL, Sig, ValRet, MLk >::size_type |
Definition at line 462 of file thread_safe_adaptors.hpp.
typedef api_threading_traits<lock_traits::api_type, typename lock_traits::model_type> jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::funky_queue< QT, M, WL, Sig, ValRet, MLk >::thread_traits |
Definition at line 459 of file thread_safe_adaptors.hpp.
typedef ValRet jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::funky_queue< QT, M, WL, Sig, ValRet, MLk >::value_ret_type |
The type to return when removing items from the queue.
Definition at line 464 of file thread_safe_adaptors.hpp.
typedef container_type::value_type jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::funky_queue< QT, M, WL, Sig, ValRet, MLk >::value_type |
Definition at line 463 of file thread_safe_adaptors.hpp.
typedef WL jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::funky_queue< QT, M, WL, Sig, ValRet, MLk >::write_lock_type |
The type of write-lock to use. This allows the possibility of using a read-write lock.
Definition at line 453 of file thread_safe_adaptors.hpp.
|
inlinenoexcept |
Definition at line 441 of file thread_safe_adaptors_impl.hpp.
References jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::funky_queue< QT, M, WL, Sig, ValRet, MLk >::have_work.
|
inlineexplicit |
Definition at line 445 of file thread_safe_adaptors_impl.hpp.
References jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::funky_queue< QT, M, WL, Sig, ValRet, MLk >::have_work.
|
inlinenoexcept |
Definition at line 449 of file thread_safe_adaptors_impl.hpp.
References jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::funky_queue< QT, M, WL, Sig, ValRet, MLk >::have_work.
|
inline |
Definition at line 458 of file thread_safe_adaptors_impl.hpp.
|
inlinenoexcept |
If the queue is long enough, then this function will not block the operation of pop() or pop_back().
Definition at line 541 of file thread_safe_adaptors_impl.hpp.
References jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::funky_queue< QT, M, WL, Sig, ValRet, MLk >::back(), and jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::funky_queue< QT, M, WL, Sig, ValRet, MLk >::serialise_size.
Referenced by jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::funky_queue< QT, M, WL, Sig, ValRet, MLk >::back().
|
inlineprotectednoexcept |
Definition at line 613 of file thread_safe_adaptors_impl.hpp.
jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::funky_queue< QT, M, WL, Sig, ValRet, MLk >::BOOST_MPL_ASSERT | ( | (std::is_same< typename write_lock_type::atomic_t, atomic_t >) | ) |
|
inlinenoexcept |
Definition at line 494 of file thread_safe_adaptors_impl.hpp.
References jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::funky_queue< QT, M, WL, Sig, ValRet, MLk >::have_work.
|
inlinenoexcept |
Definition at line 578 of file thread_safe_adaptors.hpp.
|
inlinenoexcept |
Definition at line 581 of file thread_safe_adaptors.hpp.
|
inlinenoexcept |
Definition at line 471 of file thread_safe_adaptors_impl.hpp.
|
inlinenoexcept |
This function is provided to assist with writing thread-safe code.
Definition at line 502 of file thread_safe_adaptors_impl.hpp.
References jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::funky_queue< QT, M, WL, Sig, ValRet, MLk >::have_work.
|
inlinenoexcept |
If the queue is long enough, then this function will not block the operation of push() or push_back().
Definition at line 517 of file thread_safe_adaptors_impl.hpp.
References jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::funky_queue< QT, M, WL, Sig, ValRet, MLk >::serialise_size.
|
inlinenoexcept |
Definition at line 462 of file thread_safe_adaptors_impl.hpp.
References jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::funky_queue< QT, M, WL, Sig, ValRet, MLk >::have_work.
|
inlinenoexcept |
If the queue is long enough, then this function will not block the operation of push() or push_front().
Definition at line 715 of file thread_safe_adaptors_impl.hpp.
References jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::funky_queue< QT, M, WL, Sig, ValRet, MLk >::serialise_size.
|
inlinenoexcept |
If the queue is long enough, then this function will not block the operation of push() or push_front().
Definition at line 726 of file thread_safe_adaptors_impl.hpp.
References jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::funky_queue< QT, M, WL, Sig, ValRet, MLk >::pop_front(), and jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::funky_queue< QT, M, WL, Sig, ValRet, MLk >::serialise_size.
Referenced by jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::funky_queue< QT, M, WL, Sig, ValRet, MLk >::pop_front().
|
inlinenoexcept |
Definition at line 658 of file thread_safe_adaptors_impl.hpp.
References jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::funky_queue< QT, M, WL, Sig, ValRet, MLk >::have_work.
Referenced by jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::funky_queue< QT, M, WL, Sig, ValRet, MLk >::pop_front_nochk_nolk().
|
inlinenoexcept |
Definition at line 667 of file thread_safe_adaptors_impl.hpp.
|
inlineprotectedvirtualnoexcept |
Definition at line 676 of file thread_safe_adaptors_impl.hpp.
References jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::funky_queue< QT, M, WL, Sig, ValRet, MLk >::pop_front_1_nochk_nolk().
|
inlinenoexcept |
Definition at line 693 of file thread_safe_adaptors_impl.hpp.
References jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::funky_queue< QT, M, WL, Sig, ValRet, MLk >::pop_front_nolk(), and jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::funky_queue< QT, M, WL, Sig, ValRet, MLk >::serialise_size.
Referenced by jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::funky_queue< QT, M, WL, Sig, ValRet, MLk >::pop_front_nolk().
|
inlinenoexcept |
The underlying locks, to assist in writing thread-safe code.
Definition at line 492 of file thread_safe_adaptors.hpp.
|
inlinenoexcept |
The underlying locks, to assist in writing thread-safe code.
Definition at line 488 of file thread_safe_adaptors.hpp.
|
inlinenoexcept |
If the queue is long enough, then this function will not block the operation of pop() or pop_back().
v | The value to be added. |
Definition at line 577 of file thread_safe_adaptors_impl.hpp.
References jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::funky_queue< QT, M, WL, Sig, ValRet, MLk >::have_work, and jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::funky_queue< QT, M, WL, Sig, ValRet, MLk >::serialise_size.
|
inlinenoexcept |
If the queue is long enough, then this function will not block the operation of pop() or pop_back().
v | The value to be added. |
Definition at line 565 of file thread_safe_adaptors_impl.hpp.
References jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::funky_queue< QT, M, WL, Sig, ValRet, MLk >::have_work, and jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::funky_queue< QT, M, WL, Sig, ValRet, MLk >::serialise_size.
|
inlinenoexcept |
If the queue is long enough, then this function will not block the operation of pop() or pop_back().
v | The value to be added. |
Definition at line 601 of file thread_safe_adaptors_impl.hpp.
References jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::funky_queue< QT, M, WL, Sig, ValRet, MLk >::have_work, jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::funky_queue< QT, M, WL, Sig, ValRet, MLk >::serialise_size, and jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::funky_queue< QT, M, WL, Sig, ValRet, MLk >::size().
|
inlinenoexcept |
If the queue is long enough, then this function will not block the operation of pop() or pop_back().
v | The value to be added. |
Definition at line 589 of file thread_safe_adaptors_impl.hpp.
References jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::funky_queue< QT, M, WL, Sig, ValRet, MLk >::have_work, jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::funky_queue< QT, M, WL, Sig, ValRet, MLk >::serialise_size, and jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::funky_queue< QT, M, WL, Sig, ValRet, MLk >::size().
|
inlinenoexcept |
The underlying locks, to assist in writing thread-safe code.
Definition at line 500 of file thread_safe_adaptors.hpp.
|
inlinenoexcept |
The underlying locks, to assist in writing thread-safe code.
Definition at line 496 of file thread_safe_adaptors.hpp.
|
inlinenoexcept |
e | The item to be removed from the container_type. |
Definition at line 750 of file thread_safe_adaptors_impl.hpp.
References jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::funky_queue< QT, M, WL, Sig, ValRet, MLk >::have_work.
|
inlinenoexcept |
Definition at line 488 of file thread_safe_adaptors_impl.hpp.
Referenced by jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::funky_queue< QT, M, WL, Sig, ValRet, MLk >::push_back().
|
inlinenoexcept |
Definition at line 478 of file thread_safe_adaptors_impl.hpp.
References jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::funky_queue< QT, M, WL, Sig, ValRet, MLk >::have_work.
|
mutable |
A flag to atomically signal if the container contains work or not, and how much work.
Definition at line 485 of file thread_safe_adaptors.hpp.
Referenced by jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::funky_queue< QT, M, WL, Sig, ValRet, MLk >::clear(), jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::funky_queue< QT, M, WL, Sig, ValRet, MLk >::erase(), jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::funky_queue< QT, M, WL, Sig, ValRet, MLk >::funky_queue(), jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::funky_queue< QT, M, WL, Sig, ValRet, MLk >::operator=(), jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::funky_queue< QT, M, WL, Sig, ValRet, MLk >::pop_front_1_nochk_nolk(), jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::funky_queue< QT, M, WL, Sig, ValRet, MLk >::push(), jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::funky_queue< QT, M, WL, Sig, ValRet, MLk >::push_back(), jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::funky_queue< QT, M, WL, Sig, ValRet, MLk >::remove(), and jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::funky_queue< QT, M, WL, Sig, ValRet, MLk >::sync_size().
|
staticconstexpr |
To assist in allowing compile-time computation of the algorithmic order of the threading model.
Definition at line 472 of file thread_safe_adaptors.hpp.
|
staticconstexpr |
The size of the queue, below which the push & pop operations serialise.
Definition at line 467 of file thread_safe_adaptors.hpp.
Referenced by jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::funky_queue< QT, M, WL, Sig, ValRet, MLk >::back(), jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::funky_queue< QT, M, WL, Sig, ValRet, MLk >::front(), jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::funky_queue< QT, M, WL, Sig, ValRet, MLk >::pop(), jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::funky_queue< QT, M, WL, Sig, ValRet, MLk >::pop_front(), jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::funky_queue< QT, M, WL, Sig, ValRet, MLk >::pop_front_nolk(), jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::funky_queue< QT, M, WL, Sig, ValRet, MLk >::push(), and jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::funky_queue< QT, M, WL, Sig, ValRet, MLk >::push_back().