Goby3  3.1.5a
2024.05.23
goby::acomms::DynamicSubBuffer< T, Clock > Class Template Reference

Represents a time-dependent priority queue for a single group of messages (e.g. for a single DCCL ID) More...

#include <goby/acomms/buffer/dynamic_buffer.h>

Classes

struct  Value
 

Public Types

enum  ValueResult {
  ValueResult::VALUE_PROVIDED, ValueResult::EMPTY, ValueResult::IN_BLACKOUT, ValueResult::NEXT_MESSAGE_TOO_LARGE,
  ValueResult::ALL_MESSAGES_WAITING_FOR_ACK
}
 
using size_type = typename std::deque< T >::size_type
 

Public Member Functions

 DynamicSubBuffer (const goby::acomms::protobuf::DynamicBufferConfig &cfg)
 Create a subbuffer with the given configuration. More...
 
 DynamicSubBuffer (const std::vector< goby::acomms::protobuf::DynamicBufferConfig > &cfgs)
 Create a subbuffer merging two or more configuration objects. More...
 
 ~DynamicSubBuffer ()
 
void update (const std::vector< goby::acomms::protobuf::DynamicBufferConfig > &cfgs)
 Update the configurations without clearing the buffer. More...
 
const goby::acomms::protobuf::DynamicBufferConfigcfg () const
 Return the aggregate configuration. More...
 
Valuetop (typename Clock::time_point reference=Clock::now(), typename Clock::duration ack_timeout=std::chrono::microseconds(0))
 Returns the value at the top of the queue that hasn't been sent wihin ack_timeout. More...
 
size_t top_size (typename Clock::time_point reference=Clock::now(), typename Clock::duration ack_timeout=std::chrono::microseconds(0)) const
 Returns the size (in bytes) of the top of the queue that hasn't been sent within ack_timeout. More...
 
bool all_waiting_for_ack (typename Clock::time_point reference=Clock::now(), typename Clock::duration ack_timeout=std::chrono::microseconds(0)) const
 returns true if all messages have been sent within ack_timeout of the reference provided and thus none are available for resending yet More...
 
std::pair< double, ValueResulttop_value (typename Clock::time_point reference=Clock::now(), size_type max_bytes=std::numeric_limits< size_type >::max(), typename Clock::duration ack_timeout=std::chrono::microseconds(0)) const
 Provides the numerical priority value based on this subbuffer's base priority, time-to-live (ttl) and time since last access (last call to top()) More...
 
bool in_blackout (typename Clock::time_point reference=Clock::now()) const
 Returns if buffer is in blackout. More...
 
bool empty () const
 Returns if this queue is empty. More...
 
size_type size () const
 Retrieves the size of the queue. More...
 
void pop ()
 Pop the value on the top of the queue. More...
 
std::vector< Valuepush (const T &t, typename Clock::time_point reference=Clock::now())
 Push a value to the queue. More...
 
std::vector< Valueexpire (typename Clock::time_point reference=Clock::now())
 Erase any values that have exceeded their time-to-live. More...
 
bool erase (const Value &value)
 Erase a value. More...
 

Detailed Description

template<typename T, typename Clock = goby::time::SteadyClock>
class goby::acomms::DynamicSubBuffer< T, Clock >

Represents a time-dependent priority queue for a single group of messages (e.g. for a single DCCL ID)

Definition at line 65 of file dynamic_buffer.h.

Member Typedef Documentation

◆ size_type

template<typename T , typename Clock = goby::time::SteadyClock>
using goby::acomms::DynamicSubBuffer< T, Clock >::size_type = typename std::deque<T>::size_type

Definition at line 68 of file dynamic_buffer.h.

Member Enumeration Documentation

◆ ValueResult

template<typename T , typename Clock = goby::time::SteadyClock>
enum goby::acomms::DynamicSubBuffer::ValueResult
strong
Enumerator
VALUE_PROVIDED 
EMPTY 
IN_BLACKOUT 
NEXT_MESSAGE_TOO_LARGE 
ALL_MESSAGES_WAITING_FOR_ACK 

Definition at line 206 of file dynamic_buffer.h.

Constructor & Destructor Documentation

◆ DynamicSubBuffer() [1/2]

template<typename T , typename Clock = goby::time::SteadyClock>
goby::acomms::DynamicSubBuffer< T, Clock >::DynamicSubBuffer ( const goby::acomms::protobuf::DynamicBufferConfig cfg)
inline

Create a subbuffer with the given configuration.

Definition at line 78 of file dynamic_buffer.h.

◆ DynamicSubBuffer() [2/2]

template<typename T , typename Clock = goby::time::SteadyClock>
goby::acomms::DynamicSubBuffer< T, Clock >::DynamicSubBuffer ( const std::vector< goby::acomms::protobuf::DynamicBufferConfig > &  cfgs)
inline

Create a subbuffer merging two or more configuration objects.

These configurations are merged using the following rules:

  • ttl and value_base are averaged
  • ack_required: true takes priority over false
  • newest_first: true takes priority over false
  • blackout_time: the smaller value takes precedence
  • queue_size: the larger value takes precedence

Definition at line 91 of file dynamic_buffer.h.

◆ ~DynamicSubBuffer()

template<typename T , typename Clock = goby::time::SteadyClock>
goby::acomms::DynamicSubBuffer< T, Clock >::~DynamicSubBuffer ( )
inline

Definition at line 96 of file dynamic_buffer.h.

Member Function Documentation

◆ all_waiting_for_ack()

template<typename T , typename Clock = goby::time::SteadyClock>
bool goby::acomms::DynamicSubBuffer< T, Clock >::all_waiting_for_ack ( typename Clock::time_point  reference = Clock::now(),
typename Clock::duration  ack_timeout = std::chrono::microseconds(0) 
) const
inline

returns true if all messages have been sent within ack_timeout of the reference provided and thus none are available for resending yet

Definition at line 194 of file dynamic_buffer.h.

◆ cfg()

template<typename T , typename Clock = goby::time::SteadyClock>
const goby::acomms::protobuf::DynamicBufferConfig& goby::acomms::DynamicSubBuffer< T, Clock >::cfg ( ) const
inline

Return the aggregate configuration.

Definition at line 155 of file dynamic_buffer.h.

◆ empty()

template<typename T , typename Clock = goby::time::SteadyClock>
bool goby::acomms::DynamicSubBuffer< T, Clock >::empty ( ) const
inline

Returns if this queue is empty.

Definition at line 262 of file dynamic_buffer.h.

◆ erase()

template<typename T , typename Clock = goby::time::SteadyClock>
bool goby::acomms::DynamicSubBuffer< T, Clock >::erase ( const Value value)
inline

Erase a value.

Parameters
valueValue to erase (if it exists)
Returns
true if the value was found and erase, false if the value was not found

Definition at line 323 of file dynamic_buffer.h.

◆ expire()

template<typename T , typename Clock = goby::time::SteadyClock>
std::vector<Value> goby::acomms::DynamicSubBuffer< T, Clock >::expire ( typename Clock::time_point  reference = Clock::now())
inline

Erase any values that have exceeded their time-to-live.

Returns
Vector of values that have expired and have been erased

Definition at line 295 of file dynamic_buffer.h.

◆ in_blackout()

template<typename T , typename Clock = goby::time::SteadyClock>
bool goby::acomms::DynamicSubBuffer< T, Clock >::in_blackout ( typename Clock::time_point  reference = Clock::now()) const
inline

Returns if buffer is in blackout.

Parameters
referencetime point to use for current reference when calculating blackout

Definition at line 254 of file dynamic_buffer.h.

◆ pop()

template<typename T , typename Clock = goby::time::SteadyClock>
void goby::acomms::DynamicSubBuffer< T, Clock >::pop ( )
inline

Pop the value on the top of the queue.

Definition at line 268 of file dynamic_buffer.h.

◆ push()

template<typename T , typename Clock = goby::time::SteadyClock>
std::vector<Value> goby::acomms::DynamicSubBuffer< T, Clock >::push ( const T &  t,
typename Clock::time_point  reference = Clock::now() 
)
inline

Push a value to the queue.

Parameters
tValue to push
referenceReference time to use for this value (defaults to current time)
Returns
vector of values removed due to max_queue being exceeded

Definition at line 275 of file dynamic_buffer.h.

◆ size()

template<typename T , typename Clock = goby::time::SteadyClock>
size_type goby::acomms::DynamicSubBuffer< T, Clock >::size ( ) const
inline

Retrieves the size of the queue.

Definition at line 265 of file dynamic_buffer.h.

◆ top()

template<typename T , typename Clock = goby::time::SteadyClock>
Value& goby::acomms::DynamicSubBuffer< T, Clock >::top ( typename Clock::time_point  reference = Clock::now(),
typename Clock::duration  ack_timeout = std::chrono::microseconds(0) 
)
inline

Returns the value at the top of the queue that hasn't been sent wihin ack_timeout.

Parameters
referenceCurrent time reference (defaults to now)
ack_timeoutDuration to wait before resending a value
Returns
Value to send
Exceptions
DynamicBufferNoDataExceptionno data to (re)send

Definition at line 163 of file dynamic_buffer.h.

◆ top_size()

template<typename T , typename Clock = goby::time::SteadyClock>
size_t goby::acomms::DynamicSubBuffer< T, Clock >::top_size ( typename Clock::time_point  reference = Clock::now(),
typename Clock::duration  ack_timeout = std::chrono::microseconds(0) 
) const
inline

Returns the size (in bytes) of the top of the queue that hasn't been sent within ack_timeout.

Definition at line 180 of file dynamic_buffer.h.

◆ top_value()

template<typename T , typename Clock = goby::time::SteadyClock>
std::pair<double, ValueResult> goby::acomms::DynamicSubBuffer< T, Clock >::top_value ( typename Clock::time_point  reference = Clock::now(),
size_type  max_bytes = std::numeric_limits<size_type>::max(),
typename Clock::duration  ack_timeout = std::chrono::microseconds(0) 
) const
inline

Provides the numerical priority value based on this subbuffer's base priority, time-to-live (ttl) and time since last access (last call to top())

Parameters
referencetime point to use for current reference when calculating this priority value (defaults to current time)
max_bytesthe maximum number of bytes requested
ack_timeouthow long to wait before resending the same value again
Returns
priority value for this sub buffer

Definition at line 222 of file dynamic_buffer.h.

◆ update()

template<typename T , typename Clock = goby::time::SteadyClock>
void goby::acomms::DynamicSubBuffer< T, Clock >::update ( const std::vector< goby::acomms::protobuf::DynamicBufferConfig > &  cfgs)
inline

Update the configurations without clearing the buffer.

Definition at line 99 of file dynamic_buffer.h.


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