iceoryx_posh 2.0.3
trigger_handle.hpp
1// Copyright (c) 2020, 2021 by Apex.AI Inc. All rights reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14//
15// SPDX-License-Identifier: Apache-2.0
16
17#ifndef IOX_POSH_POPO_TRIGGER_HANDLE_HPP
18#define IOX_POSH_POPO_TRIGGER_HANDLE_HPP
19
20#include "iceoryx_hoofs/cxx/method_callback.hpp"
21#include "iceoryx_posh/internal/popo/building_blocks/condition_variable_data.hpp"
22#include "iceoryx_posh/popo/trigger.hpp"
23
24#include <limits>
25#include <mutex>
26
27namespace iox
28{
29namespace popo
30{
38{
39 public:
41 TriggerHandle() noexcept;
42
48 TriggerHandle(ConditionVariableData& conditionVariableData,
49 const cxx::MethodCallback<void, uint64_t> resetCallback,
50 const uint64_t uniqueTriggerId) noexcept;
51 TriggerHandle(const TriggerHandle&) = delete;
52 TriggerHandle& operator=(const TriggerHandle&) = delete;
53
54 TriggerHandle(TriggerHandle&& rhs) noexcept;
55 TriggerHandle& operator=(TriggerHandle&& rhs) noexcept;
56 ~TriggerHandle() noexcept;
57
60 explicit operator bool() const noexcept;
61
64 bool isValid() const noexcept;
65
69 bool wasTriggered() const noexcept;
70
73 void trigger() noexcept;
74
76 void reset() noexcept;
77
79 void invalidate() noexcept;
80
82 uint64_t getUniqueId() const noexcept;
83
85 ConditionVariableData* getConditionVariableData() noexcept;
86
87 private:
88 ConditionVariableData* m_conditionVariableDataPtr = nullptr;
89 cxx::MethodCallback<void, uint64_t> m_resetCallback;
90 uint64_t m_uniqueTriggerId = Trigger::INVALID_TRIGGER_ID;
91 mutable std::recursive_mutex m_mutex;
92};
93} // namespace popo
94} // namespace iox
95
96#endif
TriggerHandle is threadsafe without restrictions in a single process. Not qualified for inter process...
Definition: trigger_handle.hpp:38
void invalidate() noexcept
invalidates the TriggerHandle without calling the reset callback
void reset() noexcept
calls the resetCallback and invalidates the TriggerHandle
uint64_t getUniqueId() const noexcept
returns the uniqueTriggerId
ConditionVariableData * getConditionVariableData() noexcept
returns the pointer to the ConditionVariableData
bool isValid() const noexcept
returns true if the TriggerHandle is valid otherwise false. A TriggerHandle is valid if m_conditionVa...
bool wasTriggered() const noexcept
Returns true when the TriggerHandle was triggered.
void trigger() noexcept
triggers the Trigger and informs the Notifyable which verifies that the Trigger was triggered by call...
The Trigger class is usually managed by a factory class like a WaitSet and acquired by classes which ...
Definition: trigger.hpp:56