Class real_time_tools::ThreadsafeObject

template<typename ...Types>
class real_time_tools::ThreadsafeObject

This object can have several types depending on what ones want to store.

tparam Types

Public Types

template<int INDEX>
using Type = typename std::tuple_element<INDEX, std::tuple<Types...>>::type

Define a specific “Type” which permit a more readable code.

Template Parameters

INDEX

Public Functions

ThreadsafeObject()

Construct a new ThreadsafeObject object.

void wait_for_update(unsigned index) const

Wait until the data with the deignated index is changed.

Parameters

index

template<unsigned INDEX = 0>
inline void wait_for_update() const

Wait until the data with the designated index is changed.

Template Parameters

INDEX=0

size_t wait_for_update() const

Wait until any data has been changed.

Returns

size_t

template<int INDEX = 0>
Type<INDEX> get() const

Getters.

Get the data with the designated index. The index is resolved at compile time.

Template Parameters

INDEX=0

Returns

Type<INDEX>

template<int INDEX = 0>
void set(Type<INDEX> datum)

Setters.

Set the data with the designated index. The index is resolved at compile time.

Template Parameters

INDEX=0

Parameters

datum

template<int INDEX>
void set(ThreadsafeObject<Types...>::Type<INDEX> datum)

Setters.

Set the data with the designated index. The index is resolved at compile time.

Template Parameters

INDEX=0

Parameters

datum

Public Static Attributes

static const std::size_t SIZE = sizeof...(Types)

Define the size of the different types.

Private Members

std::shared_ptr<std::tuple<Types...>> data_

the actual data buffers.

mutable std::shared_ptr<std::condition_variable> condition_

a condition variable that allow to wait until one data has been changed in the buffer.

mutable std::shared_ptr<std::mutex> condition_mutex_

The mutex of the condition variable.

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::shared_ptr<std::array<std::mutex, SIZE>> data_mutexes_

These are the individual mutexes of each data upon setting and getting.