|
jaffarCommon
|
#include <concurrent.hpp>
Public Member Functions | |
| __JAFFAR_COMMON_INLINE__ auto & | getInternalStorage () |
| __JAFFAR_COMMON_INLINE__ void | push_back_no_lock (T element) |
| __JAFFAR_COMMON_INLINE__ void | push_back (T element) |
| __JAFFAR_COMMON_INLINE__ void | push_front_no_lock (T element) |
| __JAFFAR_COMMON_INLINE__ void | push_front (T element) |
| __JAFFAR_COMMON_INLINE__ T | front () const |
| __JAFFAR_COMMON_INLINE__ T | back () const |
| __JAFFAR_COMMON_INLINE__ void | pop_front () |
| __JAFFAR_COMMON_INLINE__ void | pop_back () |
| __JAFFAR_COMMON_INLINE__ bool | pop_back_get (T &element) |
| __JAFFAR_COMMON_INLINE__ bool | pop_front_get (T &element) |
| __JAFFAR_COMMON_INLINE__ size_t | pop_front_get_batch (T *elements, const size_t maxCount) |
| __JAFFAR_COMMON_INLINE__ size_t | wasSize () const |
This implementation of a concurrent doble-ended queue class was created specifically for Jaffar's engine It allows for lock-free front and back push, pop, and pop_get operations It uses a single mutex to coordinate access. This could theoretically be improved, but for the time being seems to suffice
|
inline |
|
inline |
|
inline |
|
inline |
Pops (removes) the element at the back of the Deque
|
inline |
|
inline |
Pops (removes) the element at the front of the Deque
|
inline |
|
inline |
Pops (removes) up to maxCount elements from the front of the Deque under a single lock acquisition, copying them into the provided buffer in front-to-back order.
Batching amortizes the mutex cost across many elements. Under heavy multi-consumer contention (dozens of threads each pulling one element at a time, as the Jaffar engine does when the per-element work is cheap) the lock/unlock pair – not the pop itself – dominates wall time. Grabbing a run of elements per lock cuts lock-acquisition traffic by up to maxCount.
| [out] | elements | Destination buffer; must have room for at least maxCount elements |
| [in] | maxCount | Maximum number of elements to pop |
|
inline |
Pushes an element to the back of the deque with locking protection
| [in] | element | The input element to push |
|
inline |
Pushes an element to the back of the deque without any locking protection
| [in] | element | The input element to push |
|
inline |
Pushes an element to the front of the deque with locking protection
| [in] | element | The input element to push |
|
inline |
Pushes an element to the front of the deque without any locking protection
| [in] | element | The input element to push |
|
inline |
Retrieves the size of the container at the time of checking