iceoryx_doc  1.0.1
condition_variable_data.hpp
1 // Copyright (c) 2020 by Robert Bosch GmbH. All rights reserved.
2 // Copyright (c) 2021 by Apex.AI Inc. All rights reserved.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16 // SPDX-License-Identifier: Apache-2.0
17 #ifndef IOX_POSH_POPO_BUILDING_BLOCKS_CONDITION_VARIABLE_DATA_HPP
18 #define IOX_POSH_POPO_BUILDING_BLOCKS_CONDITION_VARIABLE_DATA_HPP
19 
20 #include "iceoryx_posh/iceoryx_posh_types.hpp"
21 #include "iceoryx_utils/error_handling/error_handling.hpp"
22 #include "iceoryx_utils/posix_wrapper/semaphore.hpp"
23 
24 #include <atomic>
25 
26 namespace iox
27 {
28 namespace popo
29 {
31 {
32  ConditionVariableData() noexcept;
33  ConditionVariableData(const RuntimeName_t& runtimeName) noexcept;
34 
35  ConditionVariableData(const ConditionVariableData& rhs) = delete;
37  ConditionVariableData& operator=(const ConditionVariableData& rhs) = delete;
38  ConditionVariableData& operator=(ConditionVariableData&& rhs) = delete;
39  ~ConditionVariableData() = default;
40 
41  posix::Semaphore m_semaphore =
42  std::move(posix::Semaphore::create(posix::CreateUnnamedSharedMemorySemaphore, 0u)
43  .or_else([](posix::SemaphoreError&) {
44  errorHandler(Error::kPOPO__CONDITION_VARIABLE_DATA_FAILED_TO_CREATE_SEMAPHORE,
45  nullptr,
46  ErrorLevel::FATAL);
47  })
48  .value());
49 
50  RuntimeName_t m_runtimeName;
51  std::atomic_bool m_toBeDestroyed{false};
52  std::atomic_bool m_activeNotifications[MAX_NUMBER_OF_NOTIFIERS_PER_CONDITION_VARIABLE];
53 };
54 
55 } // namespace popo
56 } // namespace iox
57 
58 #endif // IOX_POSH_POPO_BUILDING_BLOCKS_CONDITION_VARIABLE_DATA_HPP
Definition: service_description.hpp:29
Definition: condition_variable_data.hpp:31