12 #include <semaphore.h> 15 #include "../replicated.hpp" 53 std::map<
subgroup_id_t, std::reference_wrapper<ReplicatedObject>>& objects_map,
uint32_t subgroup_id_t
Type alias for the internal Subgroup IDs generated by ViewManager.
std::atomic< bool > thread_shutdown
A flag to singal the persistent thread to shutdown; set to true when the group is destroyed...
std::tuple< subgroup_id_t, persistent::version_t > persistence_request_t
PersistenceManager(std::map< subgroup_id_t, std::reference_wrapper< ReplicatedObject >> &objects_map, const persistence_callback_t &_persistence_callback)
Constructor.
void shutdown(bool wait)
shutdown the thread - wait till the thread finished or not.
std::queue< persistence_request_t > persistence_request_queue
a queue for the requests
persistence_manager_callbacks_t get_callbacks()
get the persistence callbacks.
void post_persist_request(const subgroup_id_t &subgroup_id, const persistent::version_t &version)
post a persistence request
virtual ~PersistenceManager()
default Destructor
void start()
Start the persistent thread.
void make_version(const subgroup_id_t &subgroup_id, const persistent::version_t &version, const HLC &mhlc)
make a version
void set_view_manager(ViewManager &view_manager)
PersistenceManager is responsible for persisting all the data in a group.
std::function< void(subgroup_id_t, persistent::version_t)> persistence_callback_t
std::map< subgroup_id_t, std::reference_wrapper< ReplicatedObject > > & objects_by_subgroup_id
Replicated Objects handle: TODO:make it safer.
ViewManager * view_manager
View Manager pointer.
sem_t persistence_request_sem
The semaphore for persistence request the persistent thread.
persistence_callback_t persistence_callback
persistence callback
std::atomic_flag prq_lock
lock for persistence request queue
std::tuple< persistence_manager_make_version_func_t, persistence_manager_post_persist_func_t > persistence_manager_callbacks_t
std::thread persist_thread
Thread handle.