ChimeraTK-cppext 01.07.01
Loading...
Searching...
No Matches
cppext::future_queue_base Class Reference

Type-independent base class for future_queue which does not depend on the template argument. More...

#include <future_queue.hpp>

+ Inheritance diagram for cppext::future_queue_base:
+ Collaboration diagram for cppext::future_queue_base:

Public Member Functions

size_t write_available () const
 Number of push operations which can be performed before the queue is full.
 
size_t read_available () const
 Number of pop operations which can be performed before the queue is empty.
 
bool push_exception (std::exception_ptr exception)
 Push an exception pointer (inplace of a value) into the queue.
 
bool push_overwrite_exception (std::exception_ptr exception)
 Like push_exception() but overwrite the last pushed value in case the queue is full.
 
bool empty ()
 Check if there is currently no data on the queue.
 
void wait ()
 Wait until the queue is not empty.
 
size_t size () const
 return length of the queue
 
bool operator== (const future_queue_base &other) const
 Check whether two future_queue instances use the same shared state, i.e.
 
bool operator!= (const future_queue_base &other) const
 

Protected Member Functions

 future_queue_base (const detail::shared_state_ptr &d_ptr_)
 
 future_queue_base ()
 
bool obtain_write_slot (size_t &index)
 reserve next available write slot.
 
void update_read_index_max ()
 update readIndexMax after a write operation was completed
 
size_t setNotificationQueue (future_queue< size_t, MOVE_DATA > &notificationQueue, size_t indexToSend)
 Set the notification queue in the shared state, as done in when_any.
 
cppext::detail::shared_state_baseget_notification_queue ()
 Atomically return the notification queue or increment the "previous data" counter (for wait_any).
 
void send_notification (cppext::detail::shared_state_base *notification_queue)
 Send notification to notification queue (if not nullptr).
 
void decrement_previous_data_counter ()
 Decrement the "previous data" counter used in when_any().
 

Protected Attributes

detail::shared_state_ptr d
 pointer to data used to allow sharing the queue (create multiple copies which all refer to the same queue).
 

Friends

template<typename T , typename FEATURES >
class ::cppext::future_queue
 
struct detail::shared_state_base
 
struct detail::shared_state_ptr
 
template<typename T , typename FEATURES , typename TOUT , typename CALLABLE >
struct detail::continuation_process_async
 
template<typename ITERATOR_TYPE >
future_queue< size_t, MOVE_DATAwhen_any (ITERATOR_TYPE begin, ITERATOR_TYPE end)
 Implementations of non-member functions.
 
template<typename ITERATOR_TYPE >
future_queue< void, MOVE_DATAwhen_all (ITERATOR_TYPE begin, ITERATOR_TYPE end)
 This function expects two forward iterators pointing to a region of a container of future_queue objects.
 

Detailed Description

Type-independent base class for future_queue which does not depend on the template argument.

For a description see future_queue.

Definition at line 108 of file future_queue.hpp.

Constructor & Destructor Documentation

◆ future_queue_base() [1/2]

cppext::future_queue_base::future_queue_base ( const detail::shared_state_ptr d_ptr_)
inlineprotected

Definition at line 907 of file future_queue.hpp.

◆ future_queue_base() [2/2]

cppext::future_queue_base::future_queue_base ( )
inlineprotected

Definition at line 909 of file future_queue.hpp.

Member Function Documentation

◆ decrement_previous_data_counter()

void cppext::future_queue_base::decrement_previous_data_counter ( )
inlineprotected

Decrement the "previous data" counter used in when_any().

Definition at line 796 of file future_queue.hpp.

◆ empty()

bool cppext::future_queue_base::empty ( )
inline

Check if there is currently no data on the queue.

If the queue contains data (i.e. true will be returned), the function will guarantee that this data can be accessed later e.g. thorugh front() or pop(). This guarantee holds even if the sender uses pop_overwrite().

Definition at line 873 of file future_queue.hpp.

◆ get_notification_queue()

cppext::detail::shared_state_base * cppext::future_queue_base::get_notification_queue ( )
inlineprotected

Atomically return the notification queue or increment the "previous data" counter (for wait_any).

The counter is incremented if no notification queue is set. This allows wait_any to determine how many pending values are in the value queue, so it can place corresponding notifications to the notification queue.

The call to this function must take place before signalling the receiving side of the queue, so the corresponding call to decrement_previous_data_counter() is properly synchronised.

Definition at line 769 of file future_queue.hpp.

◆ obtain_write_slot()

bool cppext::future_queue_base::obtain_write_slot ( size_t index)
inlineprotected

reserve next available write slot.

Returns false if no free slot is available or true on success.

Definition at line 911 of file future_queue.hpp.

◆ operator!=()

bool cppext::future_queue_base::operator!= ( const future_queue_base other) const
inline

Definition at line 903 of file future_queue.hpp.

◆ operator==()

bool cppext::future_queue_base::operator== ( const future_queue_base other) const
inline

Check whether two future_queue instances use the same shared state, i.e.

represent the same queue.

Definition at line 899 of file future_queue.hpp.

◆ push_exception()

bool cppext::future_queue_base::push_exception ( std::exception_ptr  exception)
inline

Push an exception pointer (inplace of a value) into the queue.

The exception gets thrown by pop()/pop_wait()/front() when the receiver reads the corresponding queue element.

Definition at line 807 of file future_queue.hpp.

◆ push_overwrite_exception()

bool cppext::future_queue_base::push_overwrite_exception ( std::exception_ptr  exception)
inline

Like push_exception() but overwrite the last pushed value in case the queue is full.

See also push_overwrite() for more information.

Definition at line 828 of file future_queue.hpp.

◆ read_available()

size_t cppext::future_queue_base::read_available ( ) const
inline

Number of pop operations which can be performed before the queue is empty.

Note that the result can be inaccurate in case the sender uses push_overwrite(). If a guarantee is required that a readable element is present before accessing it through pop() or front(), use empty().

Definition at line 764 of file future_queue.hpp.

◆ send_notification()

void cppext::future_queue_base::send_notification ( cppext::detail::shared_state_base notification_queue)
inlineprotected

Send notification to notification queue (if not nullptr).

The notification queue must be obtained before through get_notification_queue().

The call to this function must take place after signalling the receiving side of the queue, so the value is available right away when receiving the notification.

Definition at line 782 of file future_queue.hpp.

◆ setNotificationQueue()

size_t cppext::future_queue_base::setNotificationQueue ( future_queue< size_t, MOVE_DATA > &  notificationQueue,
size_t  indexToSend 
)
inlineprotected

Set the notification queue in the shared state, as done in when_any.

Returns the number of data in the queue at the time the notification queue was set (atomically).

Definition at line 936 of file future_queue.hpp.

◆ size()

size_t cppext::future_queue_base::size ( ) const
inline

return length of the queue

Definition at line 890 of file future_queue.hpp.

◆ update_read_index_max()

void cppext::future_queue_base::update_read_index_max ( )
inlineprotected

update readIndexMax after a write operation was completed

Definition at line 921 of file future_queue.hpp.

◆ wait()

void cppext::future_queue_base::wait ( )
inline

Wait until the queue is not empty.

This function guarantees similar like empty() that after this call data can be accessed e.g. through front() or pop().

Definition at line 883 of file future_queue.hpp.

◆ write_available()

size_t cppext::future_queue_base::write_available ( ) const
inline

Number of push operations which can be performed before the queue is full.

Implementation of future_queue_base.

Note that the result may be inacurate e.g. in multi-producer contexts.

Definition at line 751 of file future_queue.hpp.

Friends And Related Symbol Documentation

◆ ::cppext::future_queue

Definition at line 187 of file future_queue.hpp.

◆ detail::continuation_process_async

◆ detail::shared_state_base

Definition at line 195 of file future_queue.hpp.

◆ detail::shared_state_ptr

Definition at line 196 of file future_queue.hpp.

◆ when_all

template<typename ITERATOR_TYPE >
future_queue< void, MOVE_DATA > when_all ( ITERATOR_TYPE  begin,
ITERATOR_TYPE  end 
)
friend

This function expects two forward iterators pointing to a region of a container of future_queue objects.

It returns a future_queue<void> which will receive a notification when all of the queues in the region have received a new value.

Definition at line 590 of file future_queue.hpp.

◆ when_any

template<typename ITERATOR_TYPE >
future_queue< size_t, MOVE_DATA > when_any ( ITERATOR_TYPE  begin,
ITERATOR_TYPE  end 
)
friend

Implementations of non-member functions.

This function expects two forward iterators pointing to a region of a container of future_queue objects. It returns a future_queue which will receive the index of each queue relative to the iterator begin when the respective queue has new data available for reading. This way the returned queue can be used to get notified about each data written to any of the queues. The order of the indices in this queue is guaranteed to be in the same order the data has been written to the queues. If the same queue gets written to multiple times its index will be present in the returned queue the same number of times.

Behaviour is unspecified if, after the call to when_any(), data is popped from one of the participating queues without retreiving its index previously from the returned queue. Behaviour is also unspecified if the same queue is passed to different calls to this function, or occurres multiple times.

If push_overwrite() is used on one of the participating queues, the notifications received through the returned queue might be in a different order (i.e. when data is overwritten, the corresponding queue index is not moved to the correct place later in the notfication queue). Also, a notification for a value written to a queue with push_overwrite() might appear in the notification queue before the value can be retrieved from the data queue. It is therefore recommended to use pop_wait() to retrieve the values from the data queues if push_overwrite() is used. Otherwise failed pop() have to be retried until the data is received.

If data is already available in the queues before calling when_any(), the appropriate number of notifications are placed in the notifyer queue in arbitrary order.

Definition at line 562 of file future_queue.hpp.

Member Data Documentation

◆ d

detail::shared_state_ptr cppext::future_queue_base::d
protected

pointer to data used to allow sharing the queue (create multiple copies which all refer to the same queue).

Definition at line 184 of file future_queue.hpp.


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