16 #ifndef QUANUM_COROUTINE_POOL_ALLOCATOR 17 #define QUANUM_COROUTINE_POOL_ALLOCATOR 22 #include <type_traits> 24 #include <quantum/quantum_spinlock.h> 25 #include <boost/context/stack_context.hpp> 39 template <
typename STACK_TRAITS>
57 boost::context::stack_context
allocate();
58 void deallocate(
const boost::context::stack_context& ctx);
69 int blockIndex(
const boost::context::stack_context& ctx)
const;
70 bool isManaged(
const boost::context::stack_context& ctx)
const;
71 Header* getHeader(
const boost::context::stack_context& ctx)
const;
77 ssize_t _freeBlockIndex;
78 size_t _numHeapAllocatedBlocks;
83 template <
typename STACK_TRAITS>
91 throw std::bad_alloc();
95 boost::context::stack_context
allocate() {
return _alloc->allocate(); }
96 void deallocate(
const boost::context::stack_context& ctx) {
return _alloc->deallocate(ctx); }
99 bool isFull()
const {
return _alloc->isFull(); }
100 bool isEmpty()
const {
return _alloc->isEmpty(); }
102 std::shared_ptr<CoroutinePoolAllocator<STACK_TRAITS>> _alloc;
107 #include <quantum/impl/quantum_coroutine_pool_allocator_impl.h> 110 #endif //QUANUM_COROUTINE_POOL_ALLOCATOR Definition: quantum_coroutine_pool_allocator.h:84
STACK_TRAITS traits
Definition: quantum_coroutine_pool_allocator.h:46
Definition: quantum_buffer_impl.h:22
bool isEmpty() const
Definition: quantum_coroutine_pool_allocator.h:100
std::false_type default_constructor
Definition: quantum_coroutine_pool_allocator.h:86
virtual ~CoroutinePoolAllocator()
Definition: quantum_coroutine_pool_allocator_impl.h:83
CoroutinePoolAllocator< STACK_TRAITS > this_type
Definition: quantum_coroutine_pool_allocator.h:43
void deallocate(const boost::context::stack_context &ctx)
Definition: quantum_coroutine_pool_allocator_impl.h:123
bool isFull() const
Definition: quantum_coroutine_pool_allocator.h:99
size_t allocatedHeapBlocks() const
Definition: quantum_coroutine_pool_allocator.h:98
boost::context::stack_context allocate()
Definition: quantum_coroutine_pool_allocator.h:95
Provides fast (quasi zero-time) in-place allocation for coroutines. Coroutine stacks are pre-allocate...
Definition: quantum_coroutine_pool_allocator.h:40
size_t size_type
Definition: quantum_coroutine_pool_allocator.h:44
CoroutinePoolAllocatorProxy(uint16_t size)
Definition: quantum_coroutine_pool_allocator.h:88
bool isEmpty() const
Definition: quantum_coroutine_pool_allocator_impl.h:162
void deallocate(const boost::context::stack_context &ctx)
Definition: quantum_coroutine_pool_allocator.h:96
size_t allocatedBlocks() const
Definition: quantum_coroutine_pool_allocator.h:97
CoroutinePoolAllocator(index_type size)
Definition: quantum_coroutine_pool_allocator_impl.h:32
bool isFull() const
Definition: quantum_coroutine_pool_allocator_impl.h:156
size_t allocatedBlocks() const
Definition: quantum_coroutine_pool_allocator_impl.h:144
size_t allocatedHeapBlocks() const
Definition: quantum_coroutine_pool_allocator_impl.h:150
CoroutinePoolAllocator & operator=(const this_type &)=delete
uint16_t index_type
Definition: quantum_coroutine_pool_allocator.h:45
boost::context::stack_context allocate()
Definition: quantum_coroutine_pool_allocator_impl.h:93