8#include <dispenso/detail/small_buffer_allocator_impl.h>
16template <
size_t kChunkSize>
17SmallBufferGlobals& getSmallBufferGlobals() {
19 static SmallBufferGlobals* globals =
new SmallBufferGlobals();
23char* allocSmallBufferImpl(
size_t ordinal) {
26 return detail::SmallBufferAllocator<4>::alloc();
28 return detail::SmallBufferAllocator<8>::alloc();
30 return detail::SmallBufferAllocator<16>::alloc();
32 return detail::SmallBufferAllocator<32>::alloc();
34 return detail::SmallBufferAllocator<64>::alloc();
36 return detail::SmallBufferAllocator<128>::alloc();
38 return detail::SmallBufferAllocator<256>::alloc();
40 assert(
false &&
"Invalid small buffer ordinal requested");
45void deallocSmallBufferImpl(
size_t ordinal,
void* buf) {
48 detail::SmallBufferAllocator<4>::dealloc(
reinterpret_cast<char*
>(buf));
51 detail::SmallBufferAllocator<8>::dealloc(
reinterpret_cast<char*
>(buf));
54 detail::SmallBufferAllocator<16>::dealloc(
reinterpret_cast<char*
>(buf));
57 detail::SmallBufferAllocator<32>::dealloc(
reinterpret_cast<char*
>(buf));
60 detail::SmallBufferAllocator<64>::dealloc(
reinterpret_cast<char*
>(buf));
63 detail::SmallBufferAllocator<128>::dealloc(
reinterpret_cast<char*
>(buf));
66 detail::SmallBufferAllocator<256>::dealloc(
reinterpret_cast<char*
>(buf));
69 assert(
false &&
"Invalid small buffer ordinal requested");
73size_t approxBytesAllocatedSmallBufferImpl(
size_t ordinal) {
76 return detail::SmallBufferAllocator<4>::bytesAllocated();
78 return detail::SmallBufferAllocator<8>::bytesAllocated();
80 return detail::SmallBufferAllocator<16>::bytesAllocated();
82 return detail::SmallBufferAllocator<32>::bytesAllocated();
84 return detail::SmallBufferAllocator<64>::bytesAllocated();
86 return detail::SmallBufferAllocator<128>::bytesAllocated();
88 return detail::SmallBufferAllocator<256>::bytesAllocated();
90 assert(
false &&
"Invalid small buffer ordinal requested");
95template <
size_t kChunkSize>
96SmallBufferAllocator<kChunkSize>::PerThreadQueuingData::~PerThreadQueuingData() {
97 enqueue_bulk(buffers_, count_);
99 DISPENSO_TSAN_ANNOTATE_IGNORE_WRITES_BEGIN();
100 ptoken().~ProducerToken();
101 ctoken().~ConsumerToken();
102 DISPENSO_TSAN_ANNOTATE_IGNORE_WRITES_END();
105template class SmallBufferAllocator<4>;
106template class SmallBufferAllocator<8>;
107template class SmallBufferAllocator<16>;
108template class SmallBufferAllocator<32>;
109template class SmallBufferAllocator<64>;
110template class SmallBufferAllocator<128>;
111template class SmallBufferAllocator<256>;