21 #include <quantum/quantum_allocator.h> 26 #ifndef __QUANTUM_FUTURE_ALLOC_SIZE 27 #define __QUANTUM_FUTURE_ALLOC_SIZE __QUANTUM_DEFAULT_POOL_ALLOC_SIZE 29 #ifndef __QUANTUM_USE_DEFAULT_ALLOCATOR 30 #ifdef __QUANTUM_ALLOCATE_POOL_FROM_HEAP 46 return static_cast<Impl*>(
this)->get();
53 return static_cast<const Impl*>(
this)->getRef();
60 return static_cast<Impl*>(
this)->pull(isBufferClosed);
70 return static_cast<Impl*>(
this)->get(sync);
77 return static_cast<const Impl*>(
this)->getRef(sync);
84 return static_cast<Impl*>(
this)->pull(sync, isBufferClosed);
92 _sharedState(sharedState)
98 return _sharedState !=
nullptr;
106 return _sharedState->get();
114 return _sharedState->getRef();
121 return _sharedState->wait();
128 return _sharedState->waitFor(timeMs);
136 return _sharedState->get(sync);
144 return _sharedState->getRef(sync);
151 return _sharedState->wait(sync);
156 std::chrono::milliseconds timeMs)
const 159 return _sharedState->waitFor(sync, timeMs);
167 return _sharedState->pull(isBufferClosed);
175 return _sharedState->pull(sync, isBufferClosed);
193 #ifndef __QUANTUM_USE_DEFAULT_ALLOCATOR static AllocType & instance(std::enable_if_t<!A::default_constructor::value, uint16_t > size)
Definition: quantum_allocator.h:56
Definition: quantum_buffer_impl.h:22
BufferRetType< V > pull(bool &isBufferClosed)
Definition: quantum_future_impl.h:164
Shared state used between a Promise and a Future to exchange values.
Definition: quantum_shared_state.h:38
const NonBufferRetType< V > & getRef() const
Definition: quantum_future_impl.h:111
Definition: quantum_allocator.h:36
std::future_status waitFor(std::chrono::milliseconds timeMs) const final
Waits for the future value up to a maximum 'timeMs' milliseconds.
Definition: quantum_future_impl.h:125
std::shared_ptr< ICoroSync > Ptr
Definition: quantum_icoro_sync.h:36
StackAllocator< Future< int >, __QUANTUM_FUTURE_ALLOC_SIZE > FutureAllocator
Definition: quantum_future_impl.h:33
static void deleter(Future< T > *p)
Definition: quantum_future_impl.h:191
BufferRetType< V > pull(bool &isBufferClosed)
Pull a single value from the future buffer.
Definition: quantum_future_impl.h:58
static size_type & futureAllocSize()
Get/set if the default size for future object pools.
Definition: quantum_allocator_traits.h:124
std::enable_if_t<!Traits::IsBuffer< T >::value, typename Traits::IsBuffer< T >::Type > NonBufferRetType
Definition: quantum_traits.h:95
NonBufferRetType< V > get()
Definition: quantum_future_impl.h:103
Provides a stack-based object pool to the underlying ContiguousPoolManager. The default buffer size i...
Definition: quantum_stack_allocator.h:34
Class representing a promised future. Can only be instantiated via a Promise object.
Definition: quantum_icoro_future.h:27
void wait() const final
Waits for the future value.
Definition: quantum_future_impl.h:118
const NonBufferRetType< V > & getRef() const
Get a reference the future value.
Definition: quantum_future_impl.h:51
void ThrowFutureException(FutureState state)
Definition: quantum_future_state.h:130
const NonBufferRetType< V > & getRef(ICoroSync::Ptr sync) const
Get a reference the future value.
Definition: quantum_future_impl.h:75
std::enable_if_t< Traits::IsBuffer< T >::value, typename Traits::IsBuffer< T >::Type > BufferRetType
Definition: quantum_traits.h:93
BufferRetType< V > pull(ICoroSync::Ptr sync, bool &isBufferClosed)
Pull a single value from the future buffer.
Definition: quantum_future_impl.h:82
Shared state between Promise and Future is invalid.
NonBufferRetType< V > get()
Get the future value.
Definition: quantum_future_impl.h:44
NonBufferRetType< V > get(ICoroSync::Ptr sync)
Get the future value.
Definition: quantum_future_impl.h:68
bool valid() const final
Determines if this future still has a shared state with the corresponding promise object.
Definition: quantum_future_impl.h:96