1 #include "hmbdc/Copyright.hpp"
4 #include "hmbdc/pattern/LockFreeBufferMisc.hpp"
5 #include "hmbdc/os/Allocators.hpp"
6 #include "hmbdc/Config.hpp"
14 namespace hmbdc {
namespace pattern {
16 using Sequence = HMBDC_SEQ_TYPE;
18 using value_type =
void *;
21 max_parallel_consumer = 0xffff
24 template <
typename Allocator = os::DefaultAllocator>
25 MonoLockFreeBuffer(
size_t, uint32_t, Allocator& allocator = os::DefaultAllocator::instance);
28 size_t maxItemSize()
const;
29 size_t capacity()
const;
30 void put(
void const*,
size_t sizeHint = 0);
31 template <
typename T>
void put(T
const& item) {put(&item,
sizeof(item));}
32 template <
typename T>
void putSome(T
const& item) {put(&item, std::min(
sizeof(item), maxItemSize()));}
33 template <
typename T,
typename ...Args>
34 void putInPlace(Args&&... args) {
36 new (*s) T(std::forward<Args>(args)...);
39 template <
typename T,
typename ...Args>
40 bool tryPutInPlace(Args&&... args) {
43 new (*s) T(std::forward<Args>(args)...);
48 bool tryPut(
void const*,
size_t sizeHint = 0);
50 Sequence readSeq()
const;
59 void take(
void *,
size_t = 0);
60 bool tryTake(
void *,
size_t = 0);
63 ,
size_t maxPeekSize = std::numeric_limits<size_t>::max());
68 size_t remainingSize()
const;
69 size_t parallelConsumerAlive()
const {
return 1;}
73 size_t footprint(
size_t, uint32_t);
76 std::function<void()> freer_;
Definition: MonoLockFreeBuffer.hpp:15
Definition: LockFreeBufferMisc.hpp:23
void wasteAfterPeek(iterator, size_t, bool=false)
if size not matching - please refer to the impl for details
Definition: LockFreeBufferMisc.hpp:89