libjmmcg  release_579_6_g8cffd
A C++ library containing an eclectic mix of useful, advanced components.
jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::priority_queue< C, M, WL, Sig, ValRet > Class Template Reference

A thread-safety-assisted adaptor for a priority_queue. More...

#include <priority_queue.hpp>

Inheritance diagram for jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::priority_queue< C, M, WL, Sig, ValRet >:
[legend]
Collaboration diagram for jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::priority_queue< C, M, WL, Sig, ValRet >:
[legend]

Public Types

typedef safe_colln< C, M, WL, Sig, typename lock::any_order::all< M::lock_traits::api_type, typename M::lock_traits::model_type, M, M > > base_t
 
typedef base_t::thread_traits thread_traits
 
typedef base_t::container_type container_type
 
typedef base_t::write_lock_type write_lock_type
 
typedef base_t::read_lock_type read_lock_type
 
typedef base_t::atomic_t atomic_t
 
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
 
- Public Types inherited from jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::safe_colln< C, M, WL, Sig, lock::any_order::all< M::lock_traits::api_type, M::lock_traits::model_type, M, M > >
typedef C container_type
 The container to be adapted. 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 that will be locked in some (EREW or CREW or other) manner. 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 lock::any_order::all< M::lock_traits::api_type, M::lock_traits::model_type, M, M > lock_all_type
 The multi-lock type to use to ensured that operations on combined safe_collns are thread-safe. Note that locking them in any order reduces the likelihood of deadlock at the cost of performance. More...
 
typedef atomic_t::lock_traits lock_traits
 
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 lock_traits::exception_type exception_type
 
using exit_requested_type = typename have_work_type::atomic_t
 

Public Member Functions

constexpr priority_queue () noexcept(true) FORCE_INLINE
 
 priority_queue (typename base_t::have_work_type::atomic_t &a) noexcept(true) FORCE_INLINE
 
void __fastcall push_back (value_type const &v) noexcept(true) FORCE_INLINE
 
void __fastcall push_back (value_type &&v) noexcept(true) FORCE_INLINE
 
value_type __fastcall pop_front_1_nochk_nolk () noexcept(true) FORCE_INLINE
 
value_ret_type __fastcall pop_front_nochk_nolk () noexcept(true) FORCE_INLINE
 
value_type __fastcall pop_front_1_nochk_nosig () noexcept(true) FORCE_INLINE
 
value_ret_type __fastcall pop_front_nolk () noexcept(true) FORCE_INLINE
 
value_ret_type __fastcall pop_front () noexcept(true) FORCE_INLINE
 
- Public Member Functions inherited from jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::safe_colln< C, M, WL, Sig, lock::any_order::all< M::lock_traits::api_type, M::lock_traits::model_type, M, M > >
 BOOST_MPL_ASSERT ((std::is_same< typename write_lock_type::atomic_t, atomic_t >))
 
atomic_t &__fastcall pop_lock () noexcept(true) FORCE_INLINE
 A flag to atomically signal if the container contains work or not, how much work and the underlying lock, to assist in writing thread-safe code. More...
 
atomic_t &__fastcall pop_lock () const noexcept(true) FORCE_INLINE
 A flag to atomically signal if the container contains work or not, how much work and the underlying lock, to assist in writing thread-safe code. More...
 
atomic_t &__fastcall push_lock () noexcept(true) FORCE_INLINE
 A flag to atomically signal if the container contains work or not, how much work and the underlying lock, to assist in writing thread-safe code. More...
 
atomic_t &__fastcall push_lock () const noexcept(true) FORCE_INLINE
 A flag to atomically signal if the container contains work or not, and how much work and the underlying lock, to assist in writing thread-safe code. More...
 
__stdcall safe_colln () noexcept(noexcept(container_type()) &&noexcept(have_work_type())) FORCE_INLINE
 
 safe_colln (typename have_work_type::atomic_t &) FORCE_INLINE
 
 safe_colln (std::initializer_list< value_type >) FORCE_INLINE
 
__stdcall safe_colln (size_type const sz, value_type const &v=value_type()) FORCE_INLINE
 
__stdcall FORCE_INLINE safe_colln (size_type const sz, T1 const &, T2 const &)
 
__stdcall safe_colln (const container_type &) FORCE_INLINE
 
__stdcall safe_colln (const safe_colln &) noexcept(false) FORCE_INLINE
 
 safe_colln (size_type const sz, T1 const &, T2 const &)
 
__stdcall ~safe_colln () FORCE_INLINE
 
safe_colln &__fastcall operator= (const safe_colln &) noexcept(false) FORCE_INLINE
 
bool __fastcall empty () const noexcept(true) FORCE_INLINE
 
size_type __fastcall sync_size () const noexcept(false) FORCE_INLINE
 
size_type __fastcall size () const noexcept(true) FORCE_INLINE
 
value_type __fastcall operator[] (size_type s) const noexcept(false) FORCE_INLINE
 
void __fastcall push_back (value_type const &v) noexcept(false) FORCE_INLINE
 
void __fastcall push_back (value_type &&v) noexcept(false) FORCE_INLINE
 
void __fastcall push_front (const value_type &v) noexcept(false) FORCE_INLINE
 
void __fastcall push_front (value_type &&v) noexcept(false) FORCE_INLINE
 
size_type __fastcall erase (const value_type &v) noexcept(false) FORCE_INLINE
 
void __fastcall reserve (size_type sz) noexcept(false) FORCE_INLINE
 
void __fastcall clear () noexcept(false) FORCE_INLINE
 
void __fastcall swap (safe_colln &t) noexcept(false) FORCE_INLINE
 
void __fastcall resize_noinit_nolk (const size_type sz) noexcept(false) FORCE_INLINE
 Resize the container to the requested size, but try to minimise (re-)initialising or deleting any of the existing elements. More...
 
void __fastcall resize (const size_type sz) noexcept(false) FORCE_INLINE
 Resize the container to the requested size. More...
 
bool __fastcall operator== (safe_colln const &) const noexcept(true) FORCE_INLINE
 
bool __fastcall FORCE_INLINE operator== (safe_colln< C, M1, WL1, Sig1, MLk1 > const &) const noexcept(true)
 
bool operator== (safe_colln< C, M1, WL1, Sig1, MLk1 > const &sc) const noexcept(true)
 
container_type const & colln () const noexcept(true) FORCE_INLINE
 
container_typecolln () noexcept(true) FORCE_INLINE
 

Additional Inherited Members

- Public Attributes inherited from jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::safe_colln< C, M, WL, Sig, lock::any_order::all< M::lock_traits::api_type, M::lock_traits::model_type, M, M > >
have_work_type have_work
 A flag to atomically signal if the container contains work or not, how much work and the underlying lock, to assist in writing thread-safe code. More...
 
- Static Public Attributes inherited from jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::safe_colln< C, M, WL, Sig, lock::any_order::all< M::lock_traits::api_type, M::lock_traits::model_type, M, M > >
static constexpr generic_traits::memory_access_modes memory_access_mode
 

Detailed Description

template<typename C, typename M, typename WL, class Sig, class ValRet = typename C::value_type>
class jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::priority_queue< C, M, WL, Sig, ValRet >

A thread-safety-assisted adaptor for a priority_queue.

The algorithmic complexities of the operations is based upon those of the input collection C. By default the adapted collection does not use a read-write lock. 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.

See also
safe_colln

Definition at line 42 of file priority_queue.hpp.

Member Typedef Documentation

◆ atomic_t

template<typename C , typename M , typename WL , class Sig , class ValRet = typename C::value_type>
typedef base_t::atomic_t jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::priority_queue< C, M, WL, Sig, ValRet >::atomic_t

Definition at line 49 of file priority_queue.hpp.

◆ base_t

template<typename C , typename M , typename WL , class Sig , class ValRet = typename C::value_type>
typedef safe_colln<C, M, WL, Sig, typename lock::any_order::all<M::lock_traits::api_type, typename M::lock_traits::model_type, M, M> > jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::priority_queue< C, M, WL, Sig, ValRet >::base_t

Definition at line 44 of file priority_queue.hpp.

◆ const_reference

template<typename C , typename M , typename WL , class Sig , class ValRet = typename C::value_type>
typedef container_type::const_reference jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::priority_queue< C, M, WL, Sig, ValRet >::const_reference

Definition at line 51 of file priority_queue.hpp.

◆ container_type

template<typename C , typename M , typename WL , class Sig , class ValRet = typename C::value_type>
typedef base_t::container_type jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::priority_queue< C, M, WL, Sig, ValRet >::container_type

Definition at line 46 of file priority_queue.hpp.

◆ read_lock_type

template<typename C , typename M , typename WL , class Sig , class ValRet = typename C::value_type>
typedef base_t::read_lock_type jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::priority_queue< C, M, WL, Sig, ValRet >::read_lock_type

Definition at line 48 of file priority_queue.hpp.

◆ reference

template<typename C , typename M , typename WL , class Sig , class ValRet = typename C::value_type>
typedef container_type::reference jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::priority_queue< C, M, WL, Sig, ValRet >::reference

Definition at line 50 of file priority_queue.hpp.

◆ size_type

template<typename C , typename M , typename WL , class Sig , class ValRet = typename C::value_type>
typedef container_type::size_type jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::priority_queue< C, M, WL, Sig, ValRet >::size_type

Definition at line 52 of file priority_queue.hpp.

◆ thread_traits

template<typename C , typename M , typename WL , class Sig , class ValRet = typename C::value_type>
typedef base_t::thread_traits jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::priority_queue< C, M, WL, Sig, ValRet >::thread_traits

Definition at line 45 of file priority_queue.hpp.

◆ value_ret_type

template<typename C , typename M , typename WL , class Sig , class ValRet = typename C::value_type>
typedef ValRet jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::priority_queue< C, M, WL, Sig, ValRet >::value_ret_type

Definition at line 54 of file priority_queue.hpp.

◆ value_type

template<typename C , typename M , typename WL , class Sig , class ValRet = typename C::value_type>
typedef container_type::value_type jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::priority_queue< C, M, WL, Sig, ValRet >::value_type

Definition at line 53 of file priority_queue.hpp.

◆ write_lock_type

template<typename C , typename M , typename WL , class Sig , class ValRet = typename C::value_type>
typedef base_t::write_lock_type jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::priority_queue< C, M, WL, Sig, ValRet >::write_lock_type

Definition at line 47 of file priority_queue.hpp.

Constructor & Destructor Documentation

◆ priority_queue() [1/2]

template<typename C , typename M , typename WL , class Sig , class ValRet = typename C::value_type>
constexpr jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::priority_queue< C, M, WL, Sig, ValRet >::priority_queue ( )
inlineconstexprnoexcept

Definition at line 56 of file priority_queue.hpp.

◆ priority_queue() [2/2]

template<typename C , typename M , typename WL , class Sig , class ValRet = typename C::value_type>
jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::priority_queue< C, M, WL, Sig, ValRet >::priority_queue ( typename base_t::have_work_type::atomic_t a)
inlineexplicitnoexcept

Definition at line 58 of file priority_queue.hpp.

Member Function Documentation

◆ pop_front()

template<typename C , typename M , typename WL , class Sig , class ValRet = typename C::value_type>
value_ret_type __fastcall jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::priority_queue< C, M, WL, Sig, ValRet >::pop_front ( )
inlinenoexcept
Returns
The value popped off the queue.

Definition at line 106 of file priority_queue.hpp.

◆ pop_front_1_nochk_nolk()

template<typename C , typename M , typename WL , class Sig , class ValRet = typename C::value_type>
value_type __fastcall jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::priority_queue< C, M, WL, Sig, ValRet >::pop_front_1_nochk_nolk ( )
inlinenoexcept

Definition at line 72 of file priority_queue.hpp.

◆ pop_front_1_nochk_nosig()

template<typename C , typename M , typename WL , class Sig , class ValRet = typename C::value_type>
value_type __fastcall jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::priority_queue< C, M, WL, Sig, ValRet >::pop_front_1_nochk_nosig ( )
inlinenoexcept

Definition at line 94 of file priority_queue.hpp.

◆ pop_front_nochk_nolk()

template<typename C , typename M , typename WL , class Sig , class ValRet = typename C::value_type>
value_ret_type __fastcall jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::priority_queue< C, M, WL, Sig, ValRet >::pop_front_nochk_nolk ( )
inlinenoexcept

This is used to return a collection of items from the signalled_work_queue, in the order in which they were inserted. At least one item will be returned, and if there are sufficient items in the signalled_work_queue, then max_size items will be returned. This implies that the thread that extracts items from the queue does the work in batching them. This should only be used carefully! It isn't thread-safe!

Returns
A batch of either one or max_size items.

Definition at line 85 of file priority_queue.hpp.

◆ pop_front_nolk()

template<typename C , typename M , typename WL , class Sig , class ValRet = typename C::value_type>
value_ret_type __fastcall jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::priority_queue< C, M, WL, Sig, ValRet >::pop_front_nolk ( )
inlinenoexcept

Definition at line 100 of file priority_queue.hpp.

◆ push_back() [1/2]

template<typename C , typename M , typename WL , class Sig , class ValRet = typename C::value_type>
void __fastcall jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::priority_queue< C, M, WL, Sig, ValRet >::push_back ( value_type &&  v)
inlinenoexcept

Definition at line 66 of file priority_queue.hpp.

◆ push_back() [2/2]

template<typename C , typename M , typename WL , class Sig , class ValRet = typename C::value_type>
void __fastcall jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::priority_queue< C, M, WL, Sig, ValRet >::push_back ( value_type const &  v)
inlinenoexcept

Definition at line 61 of file priority_queue.hpp.


The documentation for this class was generated from the following file: