density
C++11 library for paged memory management, function queues, heterogeneous queues and lifo memory management
|
#include <lf_heter_queue.h>
Classes | |
class | consume_operation |
class | put_transaction |
class | reentrant_consume_operation |
class | reentrant_put_transaction |
Public Member Functions | |
constexpr | lf_heter_queue () noexcept=default |
constexpr | lf_heter_queue (const ALLOCATOR_TYPE &i_source_allocator) noexcept |
constexpr | lf_heter_queue (ALLOCATOR_TYPE &&i_source_allocator) noexcept |
lf_heter_queue (lf_heter_queue &&i_source) noexcept=default | |
lf_heter_queue & | operator= (lf_heter_queue &&i_source) noexcept |
allocator_type | get_allocator () noexcept |
allocator_type & | get_allocator_ref () noexcept |
const allocator_type & | get_allocator_ref () const noexcept |
~lf_heter_queue () | |
bool | empty () const noexcept |
void | clear () noexcept |
template<typename ELEMENT_TYPE > | |
void | push (ELEMENT_TYPE &&i_source) |
template<typename ELEMENT_TYPE , typename... CONSTRUCTION_PARAMS> | |
void | emplace (CONSTRUCTION_PARAMS &&...i_construction_params) |
void | dyn_push (const runtime_type &i_type) |
void | dyn_push_copy (const runtime_type &i_type, const void *i_source) |
void | dyn_push_move (const runtime_type &i_type, void *i_source) |
template<typename ELEMENT_TYPE > | |
put_transaction< typename std::decay< ELEMENT_TYPE >::type > | start_push (ELEMENT_TYPE &&i_source) |
template<typename ELEMENT_TYPE , typename... CONSTRUCTION_PARAMS> | |
put_transaction< ELEMENT_TYPE > | start_emplace (CONSTRUCTION_PARAMS &&...i_construction_params) |
put_transaction | start_dyn_push (const runtime_type &i_type) |
put_transaction | start_dyn_push_copy (const runtime_type &i_type, const void *i_source) |
put_transaction | start_dyn_push_move (const runtime_type &i_type, void *i_source) |
template<typename ELEMENT_TYPE > | |
bool | try_push (progress_guarantee i_progress_guarantee, ELEMENT_TYPE &&i_source) noexcept( noexcept(std::declval< lf_heter_queue >() .template try_emplace< typename std::decay< ELEMENT_TYPE >::type >( i_progress_guarantee, std::forward< ELEMENT_TYPE >(i_source)))) |
template<typename ELEMENT_TYPE , typename... CONSTRUCTION_PARAMS> | |
bool | try_emplace (progress_guarantee i_progress_guarantee, CONSTRUCTION_PARAMS &&...i_construction_params) noexcept( noexcept(std::declval< lf_heter_queue >().template try_start_emplace< ELEMENT_TYPE >( i_progress_guarantee, std::forward< CONSTRUCTION_PARAMS >(i_construction_params)...))) |
bool | try_dyn_push (progress_guarantee i_progress_guarantee, const runtime_type &i_type) |
bool | try_dyn_push_copy (progress_guarantee i_progress_guarantee, const runtime_type &i_type, const void *i_source) |
bool | try_dyn_push_move (progress_guarantee i_progress_guarantee, const runtime_type &i_type, void *i_source) |
template<typename ELEMENT_TYPE > | |
put_transaction< typename std::decay< ELEMENT_TYPE >::type > | try_start_push (progress_guarantee i_progress_guarantee, ELEMENT_TYPE &&i_source) noexcept(noexcept(std::declval< lf_heter_queue >() .template try_start_emplace< typename std::decay< ELEMENT_TYPE >::type >( i_progress_guarantee, std::forward< ELEMENT_TYPE >(i_source)))) |
template<typename ELEMENT_TYPE , typename... CONSTRUCTION_PARAMS> | |
put_transaction< ELEMENT_TYPE > | try_start_emplace (progress_guarantee i_progress_guarantee, CONSTRUCTION_PARAMS &&...i_construction_params) noexcept( noexcept(ELEMENT_TYPE(std::forward< CONSTRUCTION_PARAMS >(i_construction_params)...))&& noexcept(runtime_type(runtime_type::template make< ELEMENT_TYPE >()))) |
put_transaction | try_start_dyn_push (progress_guarantee i_progress_guarantee, const runtime_type &i_type) |
put_transaction | try_start_dyn_push_copy (progress_guarantee i_progress_guarantee, const runtime_type &i_type, const void *i_source) |
put_transaction | try_start_dyn_push_move (progress_guarantee i_progress_guarantee, const runtime_type &i_type, void *i_source) |
bool | try_pop () noexcept |
consume_operation | try_start_consume () noexcept |
bool | try_start_consume (consume_operation &i_consume) noexcept |
template<typename ELEMENT_TYPE > | |
void | reentrant_push (ELEMENT_TYPE &&i_source) |
template<typename ELEMENT_TYPE , typename... CONSTRUCTION_PARAMS> | |
void | reentrant_emplace (CONSTRUCTION_PARAMS &&...i_construction_params) |
void | reentrant_dyn_push (const runtime_type &i_type) |
void | reentrant_dyn_push_copy (const runtime_type &i_type, const void *i_source) |
void | reentrant_dyn_push_move (const runtime_type &i_type, void *i_source) |
template<typename ELEMENT_TYPE > | |
reentrant_put_transaction< typename std::decay< ELEMENT_TYPE >::type > | start_reentrant_push (ELEMENT_TYPE &&i_source) |
template<typename ELEMENT_TYPE , typename... CONSTRUCTION_PARAMS> | |
reentrant_put_transaction< ELEMENT_TYPE > | start_reentrant_emplace (CONSTRUCTION_PARAMS &&...i_construction_params) |
reentrant_put_transaction | start_reentrant_dyn_push (const runtime_type &i_type) |
reentrant_put_transaction | start_reentrant_dyn_push_copy (const runtime_type &i_type, const void *i_source) |
reentrant_put_transaction | start_reentrant_dyn_push_move (const runtime_type &i_type, void *i_source) |
template<typename ELEMENT_TYPE > | |
bool | try_reentrant_push (progress_guarantee i_progress_guarantee, ELEMENT_TYPE &&i_source) noexcept(noexcept(std::declval< lf_heter_queue >() .template try_reentrant_emplace< typename std::decay< ELEMENT_TYPE >::type >( i_progress_guarantee, std::forward< ELEMENT_TYPE >(i_source)))) |
template<typename ELEMENT_TYPE , typename... CONSTRUCTION_PARAMS> | |
bool | try_reentrant_emplace (progress_guarantee i_progress_guarantee, CONSTRUCTION_PARAMS &&...i_construction_params) noexcept( noexcept( std::declval< lf_heter_queue >().template try_start_reentrant_emplace< ELEMENT_TYPE >( i_progress_guarantee, std::forward< CONSTRUCTION_PARAMS >(i_construction_params)...))) |
bool | try_reentrant_dyn_push (progress_guarantee i_progress_guarantee, const runtime_type &i_type) |
bool | try_reentrant_dyn_push_copy (progress_guarantee i_progress_guarantee, const runtime_type &i_type, const void *i_source) |
bool | try_reentrant_dyn_push_move (progress_guarantee i_progress_guarantee, const runtime_type &i_type, void *i_source) |
template<typename ELEMENT_TYPE > | |
reentrant_put_transaction< typename std::decay< ELEMENT_TYPE >::type > | try_start_reentrant_push (progress_guarantee i_progress_guarantee, ELEMENT_TYPE &&i_source) noexcept(noexcept(std::declval< lf_heter_queue >() .template try_start_reentrant_emplace< typename std::decay< ELEMENT_TYPE >::type >( i_progress_guarantee, std::forward< ELEMENT_TYPE >(i_source)))) |
template<typename ELEMENT_TYPE , typename... CONSTRUCTION_PARAMS> | |
reentrant_put_transaction< ELEMENT_TYPE > | try_start_reentrant_emplace (progress_guarantee i_progress_guarantee, CONSTRUCTION_PARAMS &&...i_construction_params) noexcept( noexcept(ELEMENT_TYPE(std::forward< CONSTRUCTION_PARAMS >(i_construction_params)...))&& noexcept(runtime_type(runtime_type::template make< ELEMENT_TYPE >()))) |
reentrant_put_transaction | try_start_reentrant_dyn_push (progress_guarantee i_progress_guarantee, const runtime_type &i_type) |
reentrant_put_transaction | try_start_reentrant_dyn_push_copy (progress_guarantee i_progress_guarantee, const runtime_type &i_type, const void *i_source) |
reentrant_put_transaction | try_start_reentrant_dyn_push_move (progress_guarantee i_progress_guarantee, const runtime_type &i_type, void *i_source) |
bool | try_reentrant_pop () noexcept |
reentrant_consume_operation | try_start_reentrant_consume () noexcept |
bool | try_start_reentrant_consume (reentrant_consume_operation &i_consume) noexcept |
Static Public Attributes | |
static constexpr size_t | min_alignment = Base::min_alignment |
static constexpr bool | concurrent_puts = PROD_CARDINALITY == concurrency_multiple |
static constexpr bool | concurrent_consumes = CONSUMER_CARDINALITY == concurrency_multiple |
static constexpr bool | concurrent_put_consumes = true |
static constexpr bool | is_seq_cst = CONSISTENCY_MODEL == consistency_sequential |
Friends | |
void | swap (lf_heter_queue &i_first, lf_heter_queue &i_second) noexcept |
Concurrent lock-free heterogeneous FIFO container-like class template. lf_heter_queue is a concurrent version of heter_queue that uses lock free algorithms for both put transactions and put operations.
RUNTIME_TYPE | Runtime-type object used to store the actual complete type of each element. This type must satisfy the requirements of RuntimeType. The default is runtime_type. |
ALLOCATOR_TYPE | Allocator type to be used. This type must satisfy the requirements of both UntypedAllocator and PagedAllocator. The default is density::default_allocator. |
PROD_CARDINALITY | specifies whether multiple threads can do put transactions concurrently. Must be a member of density::concurrency_cardinality. |
CONSUMER_CARDINALITY | specifies whether multiple threads can do consume operations concurrently. Must be a member of density::concurrency_cardinality. |
CONSISTENCY_MODEL | Specifies whether the queue is linearizable. Must be a member of density::consistency_model. Implementation note: Currently this parameter affects only put operations, and only in case of multiple producers: in case of relaxed consistency model, for a small amount of time, during the first phase of a put transaction, the queue is truncated, so any thread can successfully put further elements, but those elements are not observable to any thread, even the one who did the put. |
Thread safeness: A thread doing put operations and another thread doing consumes don't need to be synchronized. If PROD_CARDINALITY is concurrency_multiple, multiple threads are allowed to put without any synchronization. If CONSUMER_CARDINALITY is concurrency_multiple, multiple threads are allowed to consume without any synchronization.
Exception safeness: Any function of lf_heter_queue is noexcept or provides the strong exception guarantee.
This class template uses lock-free algorithms for both put operations and consume operations. Anyway, for the overall put or consume to be lock-free, if a memory operation is necessary, it must be lock-free too. The default allocator, density::default_allocator, can manage pages in lock freedom within its current capacity (i.e. the memory it has managed until now). This capacity is composed by all the allocated, pinned, thread-owned and free pages. If the capacity must exceed its previous peek, and all the memory regions are exhausted, default_allocator must request a new memory region to the system. In this case it can't guarantee lock-freedom. The static functions default_allocator::reserve_lockfree_page_memory and default_allocator::try_reserve_lockfree_page_memory can be used to reserve a capacity in advance.
default_allocator delegates legacy memory operations to the system. Since the storage of elements whose size exceeds a fixed limit can't be allocated in a page, they require a legacy memory allocation, and in this case the put can't be lock-free.
This class template provides all the put functions provided by heter_queue, and furthermore it adds the try_ variants, that:
Also raw allocation functions have the try_ versions. They do not throw in case of failure, but just return null.
This table shows all the put functions supported by lf_heter_queue:
Group | Normal | Transactional | Reentrant | Transactional-Reentrant | Type binding | Constructor |
---|---|---|---|---|---|---|
push | Compile time | Copy/Move | ||||
emplace | Compile time | Any | ||||
dynamic push | Runtime | Default | ||||
dynamic push (copy) | Runtime | Copy | ||||
dynamic push (move) | Runtime | Move | ||||
try push | Compile time | Copy/Move | ||||
try emplace | Compile time | Any | ||||
try dynamic push | Runtime | Default | ||||
try dynamic push (copy) | Runtime | Copy | ||||
try dynamic push (move) | Runtime | Move |
|
defaultnoexcept |
Default constructor. The allocator is default-constructed.
Throws: nothing.
Implementation notes:
|
inlineexplicitnoexcept |
Constructor with allocator parameter. The allocator is copy-constructed.
i_source_allocator | source used to copy-construct the allocator. |
Throws: nothing.
Implementation notes:
|
inlineexplicitnoexcept |
Constructor with allocator parameter. The allocator is move-constructed.
i_source_allocator | source used to move-construct the allocator. |
Throws: nothing.
Implementation notes:
|
defaultnoexcept |
Move constructor. The allocator is move-constructed from the one of the source.
i_source | source to move the elements from. After the call the source is left in some valid but indeterminate state. |
Complexity: constant.
Throws: nothing.
Implementation notes:
|
inline |
Destructor.
Complexity: linear.
Effects on iterators: any iterator pointing to this queue is invalidated.
Throws: Nothing.
|
inlinenoexcept |
Move assignment. The allocator is move-assigned from the one of the source.
i_source | source to move the elements from. After the call the source is left in some valid but indeterminate state. |
Complexity: Unspecified.
Effects on iterators: Any iterator pointing to this queue or to the source queue is invalidated.
Throws: Nothing.
Implementation notes:
|
inlinenoexcept |
Returns a copy of the allocator
|
inlinenoexcept |
Returns a reference to the allocator
|
inlinenoexcept |
Returns a const reference to the allocator
|
inlinenoexcept |
Returns whether the queue contains no elements.
Complexity: Unspecified.
Throws: Nothing.
|
inlinenoexcept |
Deletes all the elements in the queue.
Complexity: linear.
Effects on iterators: any iterator is invalidated
Throws: Nothing.
|
inline |
Appends at the end of the queue an element of type ELEMENT_TYPE
, copy-constructing or move-constructing it from the source.
i_source | object to be used as source to construct of new element.
|
Requires:
ELEMENT_TYPE
must be copy constructible (in case of l-value) or move constructible (in case of r-value)Complexity: constant.
Effects on iterators: no iterator is invalidated
Throws: unspecified.
Exception guarantee: strong (in case of exception the function has no observable effects).
Examples
|
inline |
Appends at the end of the queue an element of type ELEMENT_TYPE
, in-place-constructing it from a perfect forwarded parameter pack.
Note: the template argument ELEMENT_TYPE can't be deduced from the parameters so it must explicitly specified.
i_construction_params | construction parameters for the new element. |
Requires:
ELEMENT_TYPE
must be constructible with std::forward<CONSTRUCTION_PARAMS>(i_construction_params)...
Complexity: constant.
Effects on iterators: no iterator is invalidated
Throws: unspecified.
Exception guarantee: strong (in case of exception the function has no observable effects).
Examples
|
inline |
Adds at the end of the queue an element of a type known at runtime, default-constructing it.
i_type | type of the new element. |
Requires:
RUNTIME_TYPE::default_construct
must be invokable. If RUNTIMETYPE
is runtime_type this means that default_construct
must be included in the feature list.Complexity: constant.
Effects on iterators: no iterator is invalidated
Throws: unspecified.
Exception guarantee: strong (in case of exception the function has no observable effects).
Examples
|
inline |
Appends at the end of the queue an element of a type known at runtime, copy-constructing it from the source.
i_type | type of the new element. |
i_source | pointer to the object to use as source. If this pointer does dot point to an object whose dynamic type is the target type i_type was bound to, the behavior is undefined. |
Requires:
RUNTIME_TYPE::copy_construct
must be invokable. If RUNTIMETYPE
is runtime_type this means that copy_construct
must be included in the feature list.Complexity: constant.
Effects on iterators: no iterator is invalidated
Throws: unspecified.
Exception guarantee: strong (in case of exception the function has no observable effects).
Examples
|
inline |
Adds at the end of the queue an element of a type known at runtime, move-constructing it from the source.
i_type | type of the new element |
i_source | pointer to the object to use as source. If this pointer does dot point to an object whose dynamic type is the the target type i_type was bound to, the behavior is undefined. |
Requires:
RUNTIME_TYPE::move_construct
must be invokable. If RUNTIMETYPE
is runtime_type this means that move_construct
must be included in the feature list.Complexity: constant.
Effects on iterators: no iterator is invalidated
Throws: unspecified.
Exception guarantee: strong (in case of exception the function has no observable effects).
Examples
|
inline |
Begins a transaction that appends an element of type ELEMENT_TYPE
, copy-constructing or move-constructing it from the source.
This function allocates the required space, constructs the new element, and returns a transaction object that may be used to allocate raw space associated to the element being inserted, or to alter the element in some way.
Call the member function commit on the returned transaction in order to make the effects observable. If the transaction is destroyed before commit has been called, the transaction is canceled and it has no observable effects. Until the returned transaction is committed or canceled, the queue is not in a consistent state. If any function is called in this timespan by the same thread, the behavior is undefined.
i_source | object to be used as source to construct of new element.
|
Requires:
ELEMENT_TYPE
must be copy constructible (in case of l-value) or move constructible (in case of r-value)Complexity: constant.
Effects on iterators: no iterator is invalidated
Throws: unspecified.
Exception guarantee: strong (in case of exception the function has no observable effects).
Examples
|
inline |
Begins a transaction that appends an element of a type ELEMENT_TYPE
, in-place-constructing it from a perfect forwarded parameter pack.
This function allocates the required space, constructs the new element, and returns a transaction object that may be used to allocate raw space associated to the element being inserted, or to alter the element in some way.
Call the member function commit on the returned transaction in order to make the effects observable. If the transaction is destroyed before commit has been called, the transaction is canceled and it has no observable effects. Until the returned transaction is committed or canceled, the queue is not in a consistent state. If any function is called in this timespan by the same thread, the behavior is undefined.
i_construction_params | construction parameters for the new element. |
Requires:
ELEMENT_TYPE
must be constructible with std::forward<CONSTRUCTION_PARAMS>(i_construction_params)...
Complexity: constant.
Effects on iterators: no iterator is invalidated
Throws: unspecified.
Exception guarantee: strong (in case of exception the function has no observable effects).
Examples
|
inline |
Begins a transaction that appends an element of a type known at runtime, default-constructing it.
This function allocates space for and constructs the new element, and returns a transaction object that may be used to allocate raw space associated to the element being inserted, or to alter the element in some way.
Call the member function commit on the returned transaction in order to make the effects observable. If the transaction is destroyed before commit has been called, the transaction is canceled and it has no observable effects. Until the returned transaction is committed or canceled, the queue is not in a consistent state. If any function is called in this timespan by the same thread, the behavior is undefined.
i_type | type of the new element. |
Complexity: constant.
Effects on iterators: no iterator is invalidated
Throws: unspecified.
Exception guarantee: strong (in case of exception the function has no observable effects).
Examples
|
inline |
Begins a transaction that appends an element of a type known at runtime, copy-constructing it from the source..
This function allocates space for and constructs the new element, and returns a transaction object that may be used to allocate raw space associated to the element being inserted, or to alter the element in some way.
Call the member function commit on the returned transaction in order to make the effects observable. If the transaction is destroyed before commit has been called, the transaction is canceled and it has no observable effects. Until the returned transaction is committed or canceled, the queue is not in a consistent state. If any function is called in this timespan by the same thread, the behavior is undefined.
i_type | type of the new element. |
i_source | pointer to the object to use as source. If this pointer does dot point to an object whose dynamic type is the target type i_type was bound to, the behavior is undefined. |
Complexity: constant.
Effects on iterators: no iterator is invalidated
Throws: unspecified.
Exception guarantee: strong (in case of exception the function has no observable effects).
Examples
|
inline |
Begins a transaction that appends an element of a type known at runtime, move-constructing it from the source..
This function allocates space for and constructs the new element, and returns a transaction object that may be used to allocate raw space associated to the element being inserted, or to alter the element in some way.
Call the member function commit on the returned transaction in order to make the effects observable. If the transaction is destroyed before commit has been called, the transaction is canceled and it has no observable effects. Until the returned transaction is committed or canceled, the queue is not in a consistent state. If any function is called in this timespan by the same thread, the behavior is undefined.
i_type | type of the new element. |
i_source | pointer to the object to use as source. If this pointer does dot point to an object whose dynamic type is the the target type i_type was bound to, the behavior is undefined. |
Complexity: constant.
Effects on iterators: no iterator is invalidated
Throws: unspecified.
Exception guarantee: strong (in case of exception the function has no observable effects).
Examples
|
inlinenoexcept |
Tries to append at the end of the queue an element of type ELEMENT_TYPE
, copy-constructing or move-constructing it from the source.
If the put operation can't be completed with the specified progress guarantee, this function returns false to indicate a failure, and has no observable effects. This function fails if:
i_progress_guarantee | progress guarantee to respect |
i_source | object to be used as source to construct of new element.
|
Requires:
ELEMENT_TYPE
must be copy constructible (in case of l-value) or move constructible (in case of r-value)Complexity: constant.
Effects on iterators: no iterator is invalidated
Throws: what the construction of the element and the runtime type throws (conditionally noexcept)
Exception guarantee: strong (in case of exception the function has no observable effects).
Examples
|
inlinenoexcept |
Tries to append at the end of the queue an element of type ELEMENT_TYPE
, in-place-constructing it from a perfect forwarded parameter pack.
If the put operation can't be completed with the specified progress guarantee, this function returns false to indicate a failure, and has no observable effects. This function fails if:
Note: the template argument ELEMENT_TYPE can't be deduced from the parameters so it must explicitly specified.
i_progress_guarantee | progress guarantee to respect |
i_construction_params | construction parameters for the new element. |
Requires:
ELEMENT_TYPE
must be constructible with std::forward<CONSTRUCTION_PARAMS>(i_construction_params)...
Complexity: constant.
Effects on iterators: no iterator is invalidated
Throws: what the construction of the element and the runtime type throws (conditionally noexcept)
Exception guarantee: strong (in case of exception the function has no observable effects).
Examples
|
inline |
Tries to add at the end of the queue an element of a type known at runtime, default-constructing it.
If the put operation can't be completed with the specified progress guarantee, this function returns false to indicate a failure, and has no observable effects. This function fails if:
i_progress_guarantee | progress guarantee to respect |
i_type | type of the new element. |
Requires:
RUNTIME_TYPE::default_construct
must be invokable. If RUNTIMETYPE
is runtime_type this means that default_construct
must be included in the feature list.Complexity: constant.
Effects on iterators: no iterator is invalidated
Throws: what the construction of the element and the runtime type throws
Exception guarantee: strong (in case of exception the function has no observable effects).
Examples
|
inline |
Tries to add at the end of the queue an element of a type known at runtime, copy-constructing it from the source.
If the put operation can't be completed with the specified progress guarantee, this function returns false to indicate a failure, and has no observable effects. This function fails if:
i_progress_guarantee | progress guarantee to respect |
i_type | type of the new element. |
i_source | pointer to the object to use as source. If this pointer does dot point to an object whose dynamic type is the target type i_type was bound to, the behavior is undefined. |
Requires:
RUNTIME_TYPE::copy_construct
must be invokable. If RUNTIMETYPE
is runtime_type this means that copy_construct
must be included in the feature list.Complexity: constant.
Effects on iterators: no iterator is invalidated
Throws: what the construction of the element and the runtime type throws
Exception guarantee: strong (in case of exception the function has no observable effects).
Examples
|
inline |
Tries add at the end of the queue an element of a type known at runtime, move-constructing it from the source.
If the put operation can't be completed with the specified progress guarantee, this function returns false to indicate a failure, and has no observable effects. This function fails if:
i_progress_guarantee | progress guarantee to respect |
i_type | type of the new element |
i_source | pointer to the object to use as source. If this pointer does dot point to an object whose dynamic type is the the target type i_type was bound to, the behavior is undefined. |
Requires:
RUNTIME_TYPE::move_construct
must be invokable. If RUNTIMETYPE
is runtime_type this means that move_construct
must be included in the feature list.Complexity: constant.
Effects on iterators: no iterator is invalidated
Throws: what the construction of the element and the runtime type throws
Exception guarantee: strong (in case of exception the function has no observable effects).
Examples
|
inlinenoexcept |
Tries to begin a transaction that appends an element of type ELEMENT_TYPE
, copy-constructing or move-constructing it from the source.
If the put operation can't be completed with the specified progress guarantee, this function returns an empty transaction to indicate a failure, and has no observable effects. This function fails if:
This function allocates the required space, constructs the new element, and returns a transaction object that may be used to allocate raw space associated to the element being inserted, or to alter the element in some way.
Call the member function commit on the returned transaction in order to make the effects observable. If the transaction is destroyed before commit has been called, the transaction is canceled and it has no observable effects. Until the returned transaction is committed or canceled, the queue is not in a consistent state. If any function is called in this timespan by the same thread, the behavior is undefined.
i_progress_guarantee | progress guarantee to respect |
i_source | object to be used as source to construct of new element.
|
Requires:
ELEMENT_TYPE
must be copy constructible (in case of l-value) or move constructible (in case of r-value)Complexity: constant.
Effects on iterators: no iterator is invalidated
Throws: what the construction of the element and the runtime type throws (conditionally noexcept)
Exception guarantee: strong (in case of exception the function has no observable effects).
Examples
|
inlinenoexcept |
Tries to begin a transaction that appends an element of a type ELEMENT_TYPE
, in-place-constructing it from a perfect forwarded parameter pack.
If the put operation can't be completed with the specified progress guarantee, this function returns an empty transaction to indicate a failure, and has no observable effects. This function fails if:
This function allocates the required space, constructs the new element, and returns a transaction object that may be used to allocate raw space associated to the element being inserted, or to alter the element in some way.
Call the member function commit on the returned transaction in order to make the effects observable. If the transaction is destroyed before commit has been called, the transaction is canceled and it has no observable effects. Until the returned transaction is committed or canceled, the queue is not in a consistent state. If any function is called in this timespan by the same thread, the behavior is undefined.
i_progress_guarantee | progress guarantee to respect |
i_construction_params | construction parameters for the new element. |
Requires:
ELEMENT_TYPE
must be constructible with std::forward<CONSTRUCTION_PARAMS>(i_construction_params)...
Complexity: constant.
Effects on iterators: no iterator is invalidated
Throws: what the construction of the element and of the runtime type throws (conditionally noexcept)
Exception guarantee: strong (in case of exception the function has no observable effects).
Examples
|
inline |
Tries to begin a transaction that appends an element of a type known at runtime, default-constructing it.
If the put operation can't be completed with the specified progress guarantee, this function returns an empty transaction to indicate a failure, and has no observable effects. This function fails if:
This function allocates space for and constructs the new element, and returns a transaction object that may be used to allocate raw space associated to the element being inserted, or to alter the element in some way.
Call the member function commit on the returned transaction in order to make the effects observable. If the transaction is destroyed before commit has been called, the transaction is canceled and it has no observable effects. Until the returned transaction is committed or canceled, the queue is not in a consistent state. If any function is called in this timespan by the same thread, the behavior is undefined.
i_progress_guarantee | progress guarantee to respect |
i_type | type of the new element. |
Complexity: constant.
Effects on iterators: no iterator is invalidated
Throws: what the construction of the element and the runtime type throws
Exception guarantee: strong (in case of exception the function has no observable effects).
Examples
|
inline |
Tries to begin a transaction that appends an element of a type known at runtime, copy-constructing it from the source.
If the put operation can't be completed with the specified progress guarantee, this function returns an empty transaction to indicate a failure, and has no observable effects. This function fails if:
This function allocates space for and constructs the new element, and returns a transaction object that may be used to allocate raw space associated to the element being inserted, or to alter the element in some way.
Call the member function commit on the returned transaction in order to make the effects observable. If the transaction is destroyed before commit has been called, the transaction is canceled and it has no observable effects. Until the returned transaction is committed or canceled, the queue is not in a consistent state. If any function is called in this timespan by the same thread, the behavior is undefined.
i_progress_guarantee | progress guarantee to respect |
i_type | type of the new element. |
i_source | pointer to the object to use as source. If this pointer does dot point to an object whose dynamic type is the target type i_type was bound to, the behavior is undefined. |
Complexity: constant.
Effects on iterators: no iterator is invalidated
Throws: what the construction of the element and the runtime type throws
Exception guarantee: strong (in case of exception the function has no observable effects).
Examples
|
inline |
Tries to begin a transaction that appends an element of a type known at runtime, move-constructing it from the source.
If the put operation can't be completed with the specified progress guarantee, this function returns an empty transaction to indicate a failure, and has no observable effects. This function fails if:
This function allocates space for and constructs the new element, and returns a transaction object that may be used to allocate raw space associated to the element being inserted, or to alter the element in some way.
Call the member function commit on the returned transaction in order to make the effects observable. If the transaction is destroyed before commit has been called, the transaction is canceled and it has no observable effects. Until the returned transaction is committed or canceled, the queue is not in a consistent state. If any function is called in this timespan by the same thread, the behavior is undefined.
i_progress_guarantee | progress guarantee to respect |
i_type | type of the new element. |
i_source | pointer to the object to use as source. If this pointer does dot point to an object whose dynamic type is the the target type i_type was bound to, the behavior is undefined. |
Complexity: constant.
Effects on iterators: no iterator is invalidated
Throws: what the construction of the element and the runtime type throws
Exception guarantee: strong (in case of exception the function has no observable effects).
Examples
|
inlinenoexcept |
Removes and destroy the first element of the queue, if the queue is not empty. Otherwise it has no effect. This function discards the element. Use a consume function if you want to access the element before it gets destroyed.
Complexity: constant.
Effects on iterators: any iterator pointing to the first element is invalidated
Throws: nothing
|
inlinenoexcept |
Tries to start a consume operation.
A non-empty consume must be committed for the consume to have effect.
|
inlinenoexcept |
Tries to start a consume operation using an existing consume_operation object.
i_consume | reference to a consume_operation to be used. If it is non-empty it gets canceled before trying to start the new consume. |
A non-empty consume must be committed for the consume to have effect.
This overload is similar to the one taking no arguments and returning a consume_operation, but it's more efficient if the next consumable element is in the same page of the last element i_consume has visited because in this case it doesn't perform page pinning.
|
inline |
Same to lf_heter_queue::push, but allows reentrancy: during the construction of the element the queue is in a valid state.
Examples
|
inline |
Same to lf_heter_queue::emplace, but allows reentrancy: during the construction of the element the queue is in a valid state.
Examples
|
inline |
Same to lf_heter_queue::dyn_push, but allows reentrancy: during the construction of the element the queue is in a valid state.
Examples
|
inline |
Same to lf_heter_queue::dyn_push_copy, but allows reentrancy: during the construction of the element the queue is in a valid state.
Examples
|
inline |
Same to lf_heter_queue::dyn_push_move, but allows reentrancy: during the construction of the element the queue is in a valid state.
Examples
|
inline |
Same to lf_heter_queue::start_push, but allows reentrancy: during the construction of the element, and until the state of the transaction gets destroyed, the queue is in a valid state.
Examples
|
inline |
Same to lf_heter_queue::start_emplace, but allows reentrancy: during the construction of the element, and until the state of the transaction gets destroyed, the queue is in a valid state.
Examples
|
inline |
Same to lf_heter_queue::start_dyn_push, but allows reentrancy: during the construction of the element, and until the state of the transaction gets destroyed, the queue is in a valid state.
Examples
|
inline |
Same to lf_heter_queue::start_dyn_push_copy, but allows reentrancy: during the construction of the element, and until the state of the transaction gets destroyed, the queue is in a valid state.
Examples
|
inline |
Same to lf_heter_queue::start_dyn_push_move, but allows reentrancy: during the construction of the element, and until the state of the transaction gets destroyed, the queue is in a valid state.
Examples
|
inlinenoexcept |
Same to lf_heter_queue::try_push, but allows reentrancy: during the construction of the element the queue is in a valid state.
Examples
|
inlinenoexcept |
Same to lf_heter_queue::try_emplace, but allows reentrancy: during the construction of the element the queue is in a valid state.
Examples
|
inline |
Same to lf_heter_queue::try_dyn_push, but allows reentrancy: during the construction of the element the queue is in a valid state.
Examples
|
inline |
Same to lf_heter_queue::try_dyn_push_copy, but allows reentrancy: during the construction of the element the queue is in a valid state.
Examples
|
inline |
Same to lf_heter_queue::try_dyn_push_move, but allows reentrancy: during the construction of the element the queue is in a valid state.
Examples
|
inlinenoexcept |
Same to lf_heter_queue::try_start_push, but allows reentrancy: during the construction of the element the queue is in a valid state.
Examples
|
inlinenoexcept |
Same to lf_heter_queue::try_start_emplace, but allows reentrancy: during the construction of the element the queue is in a valid state.
Examples
|
inline |
Same to lf_heter_queue::try_start_dyn_push, but allows reentrancy: during the construction of the element the queue is in a valid state.
Examples
|
inline |
Same to lf_heter_queue::try_start_dyn_push_copy, but allows reentrancy: during the construction of the element the queue is in a valid state.
Examples
|
inline |
Same to lf_heter_queue::try_start_dyn_push_move, but allows reentrancy: during the construction of the element the queue is in a valid state.
Examples
|
inlinenoexcept |
Removes and destroy the first element of the queue, if the queue is not empty. Otherwise it has no effect. This is the reentrant version of try_pop. This function discards the element. Use a consume function if you want to access the element before it gets destroyed.
Complexity: constant.
Effects on iterators: any iterator pointing to the first element is invalidated
Throws: nothing
|
inlinenoexcept |
Tries to start a reentrant consume operation. This is the reentrant version of try_start_consume.
A non-empty consume must be committed for the consume to have effect.
|
inlinenoexcept |
Tries to start a consume operation using an existing consume_operation object. This is the reentrant version of try_start_consume.
i_consume | reference to a consume_operation to be used. If it is non-empty it gets canceled before trying to start the new consume. |
A non-empty consume must be committed for the consume to have effect.
This overload is similar to the one taking no arguments and returning a consume_operation. For an lf_heter_queue there is no performance difference between the two overloads. Anyway for lock-free concurrent queue this overload may be faster.
|
friend |
Swaps two queues.
|
static |
Minimum alignment used for the storage of the elements. The storage of elements is always aligned according to the most-derived type.
|
static |
Whether multiple threads can do put operations on the same queue without any further synchronization.
|
static |
Whether multiple threads can do consume operations on the same queue without any further synchronization.
|
static |
Whether puts and consumes can be done concurrently without any further synchronization. In any case unsynchronized concurrency is constrained by concurrent_puts and concurrent_consumes.
|
static |
Whether this queue is sequential consistent.