ChimeraTK-cppext 01.07.01
Loading...
Searching...
No Matches
cppext::detail::shared_state_base Struct Reference

Internal base class for holding the data which is shared between multiple instances of the same queue. More...

#include <future_queue.hpp>

+ Inheritance diagram for cppext::detail::shared_state_base:
+ Collaboration diagram for cppext::detail::shared_state_base:

Public Member Functions

 shared_state_base (size_t length)
 
virtual ~shared_state_base ()
 Destructor must be virtual so the destructor of the derived class gets called.
 
void free ()
 Decreaces the reference count and calls "delete this" where appropriate.
 

Public Attributes

std::atomic< size_treference_count {0}
 reference count.
 
std::atomic< size_twhen_any_index
 index used in wait_any to identify the queue
 
size_t nBuffers
 the number of buffers we have allocated
 
std::vector< semaphoresemaphores
 vector of semaphores corresponding to the buffers which allows the receiver to wait for new data
 
std::vector< std::exception_ptr > exceptions
 vector of exception pointers, can be set instead of values through push_exception()
 
std::atomic< size_twriteIndex
 index of the element which will be next written
 
std::atomic< size_treadIndexMax
 maximum index which the receiver is currently allowed to read (after checking it semaphore).
 
std::atomic< size_treadIndex
 index of the element which will be next read
 
bool hasFrontOwnership
 Flag if the receiver has already ownership over the front element.
 
bool is_continuation_deferred {false}
 Flag whether this future_queue is a deferred-type continuation of another.
 
std::function< void(void)> continuation_process_deferred
 Function to be called for deferred evaulation of a single value if this queue is a continuation.
 
std::function< void(void)> continuation_process_deferred_wait
 Function to be called for deferred evaulation of a single value if this queue is a continuation.
 
bool is_continuation_async {false}
 Flag whether this future_queue is a async-type continuation of another.
 
std::thread continuation_process_async
 Thread handling async-type continuations.
 
std::atomic< boolcontinuation_process_async_terminated {false}
 Flag whether the internal thread continuation_process_async has been terminated.
 
bool is_continuation_when_all {false}
 Flag whether this future_queue is a when_all-type continuation (of many other)
 
future_queue_base continuation_origin
 If either is_continuation_deferred or is_continuation_async is true, this will point to the original queue of which *this is the continuation.
 
std::atomic< when_any_notification_infowhen_any_notification {when_any_notification_info()}
 

Detailed Description

Internal base class for holding the data which is shared between multiple instances of the same queue.

The base class does not depend on the data type and is used by future_queue_base. Instances of this class must only be created dynamically using new() (don't allocate on the stack!), but the creator must not call delete(), but rather shared_state_base's free() function, so as to correctly decrement references of this class and objects pointed to. The shared_state_base and pointers to it must no longer be used after calling free() since free() may call "delete this".

Definition at line 356 of file future_queue.hpp.

Constructor & Destructor Documentation

◆ shared_state_base()

cppext::detail::shared_state_base::shared_state_base ( size_t  length)
inline

Definition at line 357 of file future_queue.hpp.

◆ ~shared_state_base()

virtual cppext::detail::shared_state_base::~shared_state_base ( )
inlinevirtual

Destructor must be virtual so the destructor of the derived class gets called.

Definition at line 363 of file future_queue.hpp.

Member Function Documentation

◆ free()

void cppext::detail::shared_state_base::free ( )
inline

Decreaces the reference count and calls "delete this" where appropriate.

The share_state_base object and pointers to it must not be used after calling free().

Definition at line 453 of file future_queue.hpp.

Member Data Documentation

◆ continuation_origin

future_queue_base cppext::detail::shared_state_base::continuation_origin

If either is_continuation_deferred or is_continuation_async is true, this will point to the original queue of which *this is the continuation.

Definition at line 431 of file future_queue.hpp.

◆ continuation_process_async

std::thread cppext::detail::shared_state_base::continuation_process_async

Thread handling async-type continuations.

Definition at line 419 of file future_queue.hpp.

◆ continuation_process_async_terminated

std::atomic<bool> cppext::detail::shared_state_base::continuation_process_async_terminated {false}

Flag whether the internal thread continuation_process_async has been terminated.

Definition at line 423 of file future_queue.hpp.

◆ continuation_process_deferred

std::function<void(void)> cppext::detail::shared_state_base::continuation_process_deferred

Function to be called for deferred evaulation of a single value if this queue is a continuation.

Definition at line 408 of file future_queue.hpp.

◆ continuation_process_deferred_wait

std::function<void(void)> cppext::detail::shared_state_base::continuation_process_deferred_wait

Function to be called for deferred evaulation of a single value if this queue is a continuation.

This version is supposed to wait until there is data to process.

Definition at line 413 of file future_queue.hpp.

◆ exceptions

std::vector<std::exception_ptr> cppext::detail::shared_state_base::exceptions

vector of exception pointers, can be set instead of values through push_exception()

Definition at line 384 of file future_queue.hpp.

◆ hasFrontOwnership

bool cppext::detail::shared_state_base::hasFrontOwnership

Flag if the receiver has already ownership over the front element.

This flag may only be used by the receiver.

Definition at line 400 of file future_queue.hpp.

◆ is_continuation_async

bool cppext::detail::shared_state_base::is_continuation_async {false}

Flag whether this future_queue is a async-type continuation of another.

Definition at line 416 of file future_queue.hpp.

◆ is_continuation_deferred

bool cppext::detail::shared_state_base::is_continuation_deferred {false}

Flag whether this future_queue is a deferred-type continuation of another.

Definition at line 404 of file future_queue.hpp.

◆ is_continuation_when_all

bool cppext::detail::shared_state_base::is_continuation_when_all {false}

Flag whether this future_queue is a when_all-type continuation (of many other)

Definition at line 427 of file future_queue.hpp.

◆ nBuffers

size_t cppext::detail::shared_state_base::nBuffers

the number of buffers we have allocated

Definition at line 376 of file future_queue.hpp.

◆ readIndex

std::atomic<size_t> cppext::detail::shared_state_base::readIndex

index of the element which will be next read

Definition at line 396 of file future_queue.hpp.

◆ readIndexMax

std::atomic<size_t> cppext::detail::shared_state_base::readIndexMax

maximum index which the receiver is currently allowed to read (after checking it semaphore).

Often equal to writeIndex, unless write operations are currently in progress

Definition at line 393 of file future_queue.hpp.

◆ reference_count

std::atomic<size_t> cppext::detail::shared_state_base::reference_count {0}

reference count.

See shared_state_ptr for further documentation.

Definition at line 370 of file future_queue.hpp.

◆ semaphores

std::vector<semaphore> cppext::detail::shared_state_base::semaphores

vector of semaphores corresponding to the buffers which allows the receiver to wait for new data

Definition at line 380 of file future_queue.hpp.

◆ when_any_index

std::atomic<size_t> cppext::detail::shared_state_base::when_any_index

index used in wait_any to identify the queue

Definition at line 373 of file future_queue.hpp.

◆ when_any_notification

std::atomic<when_any_notification_info> cppext::detail::shared_state_base::when_any_notification {when_any_notification_info()}

Definition at line 433 of file future_queue.hpp.

◆ writeIndex

std::atomic<size_t> cppext::detail::shared_state_base::writeIndex

index of the element which will be next written

Todo:
FIXME protect handling of all indices against overruns of size_t!

Definition at line 388 of file future_queue.hpp.


The documentation for this struct was generated from the following file: