MADARA  3.4.1
madara::knowledge::CheckpointStreamer Class Reference

Implementation of BaseStreamer which writes updates to a Madara checkpoint file. More...

#include <CheckpointStreamer.h>

Inheritance diagram for madara::knowledge::CheckpointStreamer:
madara::knowledge::BaseStreamer

Public Member Functions

 CheckpointStreamer (CheckpointSettings settings, KnowledgeBase &kb, double write_hertz=10)
 Constructor. More...
 
 CheckpointStreamer (CheckpointSettings settings, ThreadSafeContext &context, double write_hertz=10)
 Constructor. More...
 
 CheckpointStreamer (CheckpointStreamer &&)=delete
 
 CheckpointStreamer (const CheckpointStreamer &)=delete
 
 ~CheckpointStreamer () override
 
void enqueue (std::string name, KnowledgeRecord record) override
 Implementation of BaseStreamer::enqueue, which stores the given parameters in an in-memory buffer, for later write to disk. More...
 
CheckpointStreameroperator= (CheckpointStreamer &&)=delete
 
CheckpointStreameroperator= (const CheckpointStreamer &)=delete
 

Private Types

using pair_type = std::pair< std::string, KnowledgeRecord >
 

Private Member Functions

void terminate ()
 

Static Private Member Functions

static void thread_main (CheckpointStreamer *self)
 

Private Attributes

ThreadSafeContextcontext_
 
std::vector< pair_typein_buffer
 
std::atomic_flag keep_running_
 
std::vector< pair_typeout_buffer
 
CheckpointSettings settings_
 
std::thread thread_
 
double write_hertz_ = 10
 

Detailed Description

Implementation of BaseStreamer which writes updates to a Madara checkpoint file.

Updates are kept in an in-memory buffer, and written to disk at the hertz rate specified in the constructor.

Definition at line 32 of file CheckpointStreamer.h.

Member Typedef Documentation

◆ pair_type

using madara::knowledge::CheckpointStreamer::pair_type = std::pair<std::string, KnowledgeRecord>
private

Definition at line 100 of file CheckpointStreamer.h.

Constructor & Destructor Documentation

◆ CheckpointStreamer() [1/4]

madara::knowledge::CheckpointStreamer::CheckpointStreamer ( CheckpointSettings  settings,
ThreadSafeContext context,
double  write_hertz = 10 
)
inline

Constructor.

Parameters
settingsthe CheckpointSettings used in calls to ThreadSafeContext::save_checkpoint. The variables_lister and reset_checkpoint fields given are ignored.
contextThreadSafeContext this object is attached to. This context will be locked for a short time each period.
write_hertzhertz rate for periodic write to disk.

Definition at line 45 of file CheckpointStreamer.h.

◆ CheckpointStreamer() [2/4]

madara::knowledge::CheckpointStreamer::CheckpointStreamer ( CheckpointSettings  settings,
KnowledgeBase kb,
double  write_hertz = 10 
)
inline

Constructor.

Parameters
settingsthe CheckpointSettings used in calls to ThreadSafeContext::save_checkpoint. The variables_lister and reset_checkpoint fields given are ignored.
kbKnoweldgeBase this object is attached to. This KnoweldgeBase will be locked for a short time each period.
write_hertzhertz rate for periodic write to disk.

Definition at line 64 of file CheckpointStreamer.h.

◆ CheckpointStreamer() [3/4]

madara::knowledge::CheckpointStreamer::CheckpointStreamer ( const CheckpointStreamer )
delete

◆ CheckpointStreamer() [4/4]

madara::knowledge::CheckpointStreamer::CheckpointStreamer ( CheckpointStreamer &&  )
delete

◆ ~CheckpointStreamer()

madara::knowledge::CheckpointStreamer::~CheckpointStreamer ( )
override

Definition at line 113 of file CheckpointStreamer.cpp.

Member Function Documentation

◆ enqueue()

void madara::knowledge::CheckpointStreamer::enqueue ( std::string  name,
KnowledgeRecord  record 
)
overridevirtual

Implementation of BaseStreamer::enqueue, which stores the given parameters in an in-memory buffer, for later write to disk.

Implements madara::knowledge::BaseStreamer.

Definition at line 22 of file CheckpointStreamer.cpp.

◆ operator=() [1/2]

CheckpointStreamer& madara::knowledge::CheckpointStreamer::operator= ( CheckpointStreamer &&  )
delete

◆ operator=() [2/2]

CheckpointStreamer& madara::knowledge::CheckpointStreamer::operator= ( const CheckpointStreamer )
delete

◆ terminate()

void madara::knowledge::CheckpointStreamer::terminate ( )
inlineprivate

Definition at line 88 of file CheckpointStreamer.h.

◆ thread_main()

void madara::knowledge::CheckpointStreamer::thread_main ( CheckpointStreamer self)
staticprivate

Definition at line 69 of file CheckpointStreamer.cpp.

Member Data Documentation

◆ context_

ThreadSafeContext* madara::knowledge::CheckpointStreamer::context_
private

Definition at line 98 of file CheckpointStreamer.h.

◆ in_buffer

std::vector<pair_type> madara::knowledge::CheckpointStreamer::in_buffer
private

Definition at line 102 of file CheckpointStreamer.h.

◆ keep_running_

std::atomic_flag madara::knowledge::CheckpointStreamer::keep_running_
private

Definition at line 107 of file CheckpointStreamer.h.

◆ out_buffer

std::vector<pair_type> madara::knowledge::CheckpointStreamer::out_buffer
private

Definition at line 103 of file CheckpointStreamer.h.

◆ settings_

CheckpointSettings madara::knowledge::CheckpointStreamer::settings_
private

Definition at line 97 of file CheckpointStreamer.h.

◆ thread_

std::thread madara::knowledge::CheckpointStreamer::thread_
private

Definition at line 108 of file CheckpointStreamer.h.

◆ write_hertz_

double madara::knowledge::CheckpointStreamer::write_hertz_ = 10
private

Definition at line 105 of file CheckpointStreamer.h.


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