iceoryx_posh/internal/popo/building_blocks/condition_listener.hpp🔗
Namespaces🔗
Name |
---|
iox |
iox::popo |
Classes🔗
Name | |
---|---|
class | iox::popo::ConditionListener ConditionListener allows one to wait using a shared memory condition variable. |
Source code🔗
// Copyright (c) 2020 by Robert Bosch GmbH. All rights reserved.
// Copyright (c) 2021 by Apex.AI Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// SPDX-License-Identifier: Apache-2.0
#ifndef IOX_POSH_POPO_BUILDING_BLOCKS_CONDITION_LISTENER_HPP
#define IOX_POSH_POPO_BUILDING_BLOCKS_CONDITION_LISTENER_HPP
#include "iceoryx_posh/internal/popo/building_blocks/condition_variable_data.hpp"
#include "iceoryx_posh/mepoo/memory_info.hpp"
#include "iceoryx_utils/cxx/helplets.hpp"
namespace iox
{
namespace popo
{
class ConditionListener
{
public:
using NotificationVector_t = cxx::vector<cxx::BestFittingType_t<MAX_NUMBER_OF_NOTIFIERS_PER_CONDITION_VARIABLE>,
MAX_NUMBER_OF_NOTIFIERS_PER_CONDITION_VARIABLE>;
explicit ConditionListener(ConditionVariableData& condVarData) noexcept;
~ConditionListener() noexcept = default;
ConditionListener(const ConditionListener& rhs) = delete;
ConditionListener(ConditionListener&& rhs) noexcept = delete;
ConditionListener& operator=(const ConditionListener& rhs) = delete;
ConditionListener& operator=(ConditionListener&& rhs) noexcept = delete;
bool wasNotified() const noexcept;
void destroy() noexcept;
NotificationVector_t wait() noexcept;
NotificationVector_t timedWait(const units::Duration& timeToWait) noexcept;
protected:
const ConditionVariableData* getMembers() const noexcept;
ConditionVariableData* getMembers() noexcept;
private:
void reset(const uint64_t index) noexcept;
void resetSemaphore() noexcept;
NotificationVector_t waitImpl(const cxx::function_ref<bool()>& waitCall) noexcept;
private:
ConditionVariableData* m_condVarDataPtr{nullptr};
std::atomic_bool m_toBeDestroyed{false};
};
} // namespace popo
} // namespace iox
#endif // IOX_POSH_POPO_BUILDING_BLOCKS_CONDITION_VARIABLE_WAITER_HPP
Updated on 31 May 2022 at 15:29:16 CEST