Namespace synchronizerΒΆ
-
namespace synchronizer
-
class Follower
- #include <follower.hpp>
Public Functions
-
Follower(std::string memory_segment_, double async_frequency, bool sync_on_start = false)
Tools for setting a process to run alternatively asynchronously (i.e.
at own desired frequency) or synchronously to another process managed by a Leader using the same memory_segment id. At startup, the follower will init to async mode, and will switch to synchronous if the function set_sync of the leader is called. Note that as follower needs to be started before its leader, and can survive several leaders. param[in] memory_segment segment id of the shared memory shared between the leader and the follower param[in] frequency the follower will run at when in async mode
-
~Follower()
-
void pulse()
Either sleep to matches the frequency (async mode) or uses internally wait/notify functions to alternate run with the leader (sync mode)
-
Follower(std::string memory_segment_, double async_frequency, bool sync_on_start = false)
-
class Follower_sync
- #include <follower_sync.hpp>
Public Functions
-
Follower_sync(std::string memory_segment_, double async_frequency, bool sync_on_start = false)
-
~Follower_sync()
-
void reinit()
-
void clean_memory()
-
void wait()
-
void notify()
-
bool pulse()
-
bool read_sync_mode()
Private Members
-
std::unique_ptr<shared_memory::LockedConditionVariable> cv_
-
bool is_sync_mode_
-
bool previous_mode_
-
std::string memory_segment_
-
real_time_tools::Spinner spinner_
-
double async_frequency_
-
bool sync_on_start_
-
Follower_sync(std::string memory_segment_, double async_frequency, bool sync_on_start = false)
-
class Leader
- #include <leader.hpp>
Public Functions
-
Leader(std::string memory_segment, bool sync_on_start = false)
Tools for setting a process managed by a Follower to run either asynchronously to the process managed by the leader (i.e.
both processes run in parallel ignoring each other) or to run synchronously to another process managed the Leader (i.e. the two processes run alternatively) At startup, the follower will init to async mode, and will switch to sync mode when the corresponding call to the start_sync of the leader is called. Note that as follower needs to be started before its leader, and can survive several leaders. param[in] memory_segment segment id of the shared memory shared between the leader and the follower
-
~Leader()
-
void start_sync(long int timeout_us = -1)
Request the leader and the follower to start running synchronously param[in] the timeout (in micro seconds) the leader should wait to get the acknowledgment from the follower the request to run sync has been received.
Infinite wait if negative.
-
void stop_sync()
Request the leader and follower to switch to async mode.
-
void pulse()
Either does nothing (async mode) or uses internally wait/notify functions to alternate run with the follower (sync mode)
-
Leader(std::string memory_segment, bool sync_on_start = false)
-
class Leader_sync
- #include <leader_sync.hpp>
Public Functions
-
Leader_sync(std::string memory_segment, bool sync_on_start = false)
-
void wait()
-
void notify()
-
void pulse()
-
void start_sync(long int timeout)
-
void stop_sync()
Private Members
-
std::string memory_segment_
-
bool is_sync_mode_
-
shared_memory::LockedConditionVariable cv_
-
Leader_sync(std::string memory_segment, bool sync_on_start = false)
-
class Follower