17#ifndef IOX_POSH_POPO_WAIT_SET_HPP
18#define IOX_POSH_POPO_WAIT_SET_HPP
20#include "iceoryx_hoofs/cxx/algorithm.hpp"
21#include "iceoryx_hoofs/cxx/function_ref.hpp"
22#include "iceoryx_hoofs/cxx/helplets.hpp"
23#include "iceoryx_hoofs/cxx/list.hpp"
24#include "iceoryx_hoofs/cxx/method_callback.hpp"
25#include "iceoryx_hoofs/cxx/stack.hpp"
26#include "iceoryx_hoofs/cxx/vector.hpp"
27#include "iceoryx_posh/iceoryx_posh_types.hpp"
28#include "iceoryx_posh/internal/popo/building_blocks/condition_listener.hpp"
29#include "iceoryx_posh/internal/popo/building_blocks/condition_variable_data.hpp"
30#include "iceoryx_posh/popo/enum_trigger_type.hpp"
31#include "iceoryx_posh/popo/notification_attorney.hpp"
32#include "iceoryx_posh/popo/notification_callback.hpp"
33#include "iceoryx_posh/popo/notification_info.hpp"
34#include "iceoryx_posh/popo/trigger.hpp"
35#include "iceoryx_posh/popo/trigger_handle.hpp"
36#include "iceoryx_posh/runtime/posh_runtime.hpp"
46enum class WaitSetError : uint8_t
59template <u
int64_t Capacity = MAX_NUMBER_OF_ATTACHMENTS_PER_WAITSET>
63 static constexpr uint64_t CAPACITY = Capacity;
64 using TriggerArray = cxx::optional<Trigger>[Capacity];
65 using NotificationInfoVector = cxx::vector<const NotificationInfo*, CAPACITY>;
92 typename ContextDataType = internal::NoType_t,
93 typename = std::enable_if_t<std::is_enum<EventType>::value>>
94 cxx::expected<WaitSetError>
96 const EventType eventType,
97 const uint64_t notificationId = 0U,
106 template <
typename T,
108 typename ContextDataType = internal::NoType_t,
109 typename = std::enable_if_t<std::is_enum<EventType>::value,
void>>
111 const EventType eventType,
120 template <
typename T,
typename ContextDataType =
internal::NoType_t>
121 cxx::expected<WaitSetError>
123 const uint64_t notificationId = 0U,
131 template <
typename T,
typename ContextDataType =
internal::NoType_t>
142 template <
typename T,
144 typename ContextDataType = internal::NoType_t,
145 typename = std::enable_if_t<std::is_enum<StateType>::value>>
146 cxx::expected<WaitSetError>
148 const StateType stateType,
149 const uint64_t
id = 0U,
158 template <
typename T,
160 typename ContextDataType = internal::NoType_t,
161 typename = std::enable_if_t<std::is_enum<StateType>::value,
void>>
163 const StateType stateType,
172 template <
typename T,
typename ContextDataType =
internal::NoType_t>
173 cxx::expected<WaitSetError>
175 const uint64_t
id = 0U,
183 template <
typename T,
typename ContextDataType =
internal::NoType_t>
190 template <
typename T,
typename... Targs>
196 template <
typename T,
typename... Targs>
202 NotificationInfoVector
timedWait(
const units::Duration timeout)
noexcept;
206 NotificationInfoVector
wait() noexcept;
209 uint64_t
size() const noexcept;
215 explicit
WaitSet(ConditionVariableData& condVarData) noexcept;
218 enum class NoStateEnumUsed : StateEnumIdentifier
223 enum class NoEventEnumUsed : EventEnumIdentifier
228 using WaitFunction = cxx::function_ref<ConditionListener::NotificationVector_t()>;
229 template <
typename T,
typename ContextDataType>
230 cxx::expected<uint64_t, WaitSetError> attachImpl(T& eventOrigin,
231 const WaitSetIsConditionSatisfiedCallback& hasTriggeredCallback,
232 const uint64_t notificationId,
233 const NotificationCallback<T, ContextDataType>& eventCallback,
234 const uint64_t originType,
235 const uint64_t originTypeHash)
noexcept;
237 NotificationInfoVector waitAndReturnTriggeredTriggers(
const WaitFunction&
wait)
noexcept;
238 NotificationInfoVector createVectorWithTriggeredTriggers() noexcept;
240 void removeTrigger(const uint64_t uniqueTriggerId) noexcept;
241 void removeAllTriggers() noexcept;
242 void acquireNotifications(const WaitFunction&
wait) noexcept;
246 TriggerArray m_triggerArray;
247 ConditionVariableData* m_conditionVariableDataPtr{
nullptr};
248 ConditionListener m_conditionListener;
250 cxx::stack<uint64_t, Capacity> m_indexRepository;
251 ConditionListener::NotificationVector_t m_activeNotifications;
257#include "iceoryx_posh/internal/popo/wait_set.inl"
Logical disjunction of a certain number of Triggers.
Definition: wait_set.hpp:61
NotificationInfoVector wait() noexcept
Blocking wait till one or more of the triggers are triggered.
void markForDestruction() noexcept
Non-reversible call. After this call wait() and timedWait() do not block any longer and never return ...
cxx::expected< WaitSetError > attachEvent(T &eventOrigin, const uint64_t notificationId=0U, const NotificationCallback< T, ContextDataType > &eventCallback={}) noexcept
attaches an event of a given class to the WaitSet.
static constexpr uint64_t capacity() noexcept
returns the maximum amount of triggers which can be acquired from a waitset
NotificationInfoVector timedWait(const units::Duration timeout) noexcept
Blocking wait with time limit till one or more of the triggers are triggered.
cxx::expected< WaitSetError > attachEvent(T &eventOrigin, const EventType eventType, const uint64_t notificationId=0U, const NotificationCallback< T, ContextDataType > &eventCallback={}) noexcept
attaches an event of a given class to the WaitSet.
cxx::expected< WaitSetError > attachState(T &stateOrigin, const NotificationCallback< T, ContextDataType > &stateCallback) noexcept
attaches a state of a given class to the WaitSet.
cxx::expected< WaitSetError > attachState(T &stateOrigin, const StateType stateType, const uint64_t id=0U, const NotificationCallback< T, ContextDataType > &stateCallback={}) noexcept
attaches a state of a given class to the WaitSet.
void detachState(T &stateOrigin, const Targs &... args) noexcept
detaches a state based trigger from the WaitSet
cxx::expected< WaitSetError > attachState(T &stateOrigin, const uint64_t id=0U, const NotificationCallback< T, ContextDataType > &stateCallback={}) noexcept
attaches a state of a given class to the WaitSet.
cxx::expected< WaitSetError > attachState(T &stateOrigin, const StateType stateType, const NotificationCallback< T, ContextDataType > &stateCallback) noexcept
attaches a state of a given class to the WaitSet.
WaitSet(const WaitSet &rhs)=delete
all the Trigger have a pointer pointing to this waitset for cleanup calls, therefore the WaitSet cann...
void detachEvent(T &eventOrigin, const Targs &... args) noexcept
detaches an event from the WaitSet
uint64_t size() const noexcept
Returns the amount of stored Trigger inside of the WaitSet.
cxx::expected< WaitSetError > attachEvent(T &eventOrigin, const EventType eventType, const NotificationCallback< T, ContextDataType > &eventCallback) noexcept
attaches an event of a given class to the WaitSet.
cxx::expected< WaitSetError > attachEvent(T &eventOrigin, const NotificationCallback< T, ContextDataType > &eventCallback) noexcept
attaches an event of a given class to the WaitSet.
the struct describes a callback with a user defined type which can be attached to a WaitSet or a List...
Definition: notification_callback.hpp:58