Class real_time_tools::SingletypeThreadsafeObject¶
-
template<typename
Type
, size_tSIZE
>
classreal_time_tools
::
SingletypeThreadsafeObject
¶ The SingletypeThreadsafeObject is a thread safe object.
- Template Parameters
Type
: is the data type to store in the buffer.SIZE
: is the size of the buffer. It is better to know it at compile time to be 100% real time safe.
Public Functions
-
SingletypeThreadsafeObject
()¶ Construct a new SingletypeThreadsafeObject object.
-
SingletypeThreadsafeObject
(const std::vector<std::string> &names)¶ Construct a new SingletypeThreadsafeObject object.
- Parameters
names
:
-
void
wait_for_update
(const size_t &index) const¶ Wait until the data at the given index is modified.
- Parameters
index
:
-
void
wait_for_update
(const std::string &name) const¶ Wait until the data at the given name is modified.
- Parameters
name
:
-
size_t
wait_for_update
() const¶ Wait unitl any data has been changed and return its index.
- Return
size_t
-
size_t
size
()¶ Getters.
get size.
- Return
size_t
-
Type
get
(const size_t &index = 0) const¶ Get the data by its index in the buffer.
- Return
Type
- Parameters
index
:
-
Type
get
(const std::string &name) const¶ Get the data by its name in the buffer.
- Return
Type
- Parameters
name
:
-
template<int
INDEX
= 0>
Typeget
() const¶ Get the data by its index in the buffer.
Index is solved during compile time
- Return
Type
- Template Parameters
INDEX=0
:
-
void
set
(const Type &datum, const size_t &index = 0)¶ Setters.
Set one element at a designated index.
- Parameters
datum
:index
:
Private Members
-
std::shared_ptr<std::array<size_t, SIZE>>
modification_counts_
¶ This is counting the data modification occurences for each individual buffers.
-
std::shared_ptr<size_t>
total_modification_count_
¶ This is counting the all data modification occurences for all buffer.
/todo Can’t we just some the modification_counts_ array whenever needed?
-
std::map<std::string, size_t>
name_to_index_
¶ This is the map that allow to deal with data by their names.
-
std::shared_ptr<std::condition_variable>
condition_
¶ This condition variable is used to wait untils any data has been changed.
-
std::shared_ptr<std::mutex>
condition_mutex_
¶ This is the mutex of the condition varaible.