aether::external_storage_base< tick_data_type > Class Template Referenceabstract

Base class for implementing write access to external storage, used by aether::entity_based_user_state::build_external_storage and aether::global_state_base::build_external_storage. More...

#include <external_storage.hh>

Public Types

using get_data_fn_type = std::function< std::optional< tick_data_type >(const storage_state &)>
 

Public Member Functions

 external_storage_base (get_data_fn_type _get_data)
 Takes a function returning the data to be stored for the current simulation tick by the store method. More...
 
bool get_tick_data (const storage_state &storage_state) final
 Called by aether to check if there's any data that needs to be provided to the external storage implementation. More...
 
void store_tick_data (const storage_state &storage_state) final
 Called by aether to forward the data to the user provided store implementation. More...
 
virtual void store (const storage_state &storage_state, tick_data_type &&data)=0
 Consumes the data from simulation thread and submits it to user-provided storage. More...
 
virtual void store_tick_data_ack (uint64_t completed_tick)
 Called when all workers have finished their writes for a given tick, if any. More...
 
virtual ~external_storage_base ()
 Cleans up the storage state. More...
 

Detailed Description

template<typename tick_data_type>
class aether::external_storage_base< tick_data_type >

Base class for implementing write access to external storage, used by aether::entity_based_user_state::build_external_storage and aether::global_state_base::build_external_storage.

Maintains the state used by the external storage background thread. See Simualation/External-Stroage documentation for more details.

Member Typedef Documentation

template<typename tick_data_type >
using aether::external_storage_base< tick_data_type >::get_data_fn_type = std::function<std::optional<tick_data_type>(const storage_state&)>

Constructor & Destructor Documentation

template<typename tick_data_type >
aether::external_storage_base< tick_data_type >::external_storage_base ( get_data_fn_type  _get_data)
inline

Takes a function returning the data to be stored for the current simulation tick by the store method.

The _get_data function will be called on the main simulation thread, after cell_tick; _get_data will not be called if storing the data for the previous tick wasn't finished on all workers, will be called on the first tick after which the storage is complete Called from the simulation thread, the result is handed off to the background storage thread.

template<typename tick_data_type >
virtual aether::external_storage_base< tick_data_type >::~external_storage_base ( )
inlinevirtual

Cleans up the storage state.

At the moment it's not guaranteed to be always called on simulation shutdown.

Member Function Documentation

template<typename tick_data_type >
bool aether::external_storage_base< tick_data_type >::get_tick_data ( const storage_state storage_state)
inlinefinalvirtual

Called by aether to check if there's any data that needs to be provided to the external storage implementation.

Implements aether::external_storage_iface.

template<typename tick_data_type >
virtual void aether::external_storage_base< tick_data_type >::store ( const storage_state storage_state,
tick_data_type &&  data 
)
pure virtual

Consumes the data from simulation thread and submits it to user-provided storage.

Will only be called when _get_data was called and it returned a value. Called from the background storage thread.

template<typename tick_data_type >
void aether::external_storage_base< tick_data_type >::store_tick_data ( const storage_state storage_state)
inlinefinalvirtual

Called by aether to forward the data to the user provided store implementation.

Implements aether::external_storage_iface.

template<typename tick_data_type >
virtual void aether::external_storage_base< tick_data_type >::store_tick_data_ack ( uint64_t  completed_tick)
inlinevirtual

Called when all workers have finished their writes for a given tick, if any.

Useful when using an append-based data model: enables notifying the database that all the updates for a given tick_id have been committed, so that the readers can safely read the data for this tick. Called from the background storage thread.

Implements aether::external_storage_iface.