Skip to content

iceoryx_posh/internal/popo/building_blocks/chunk_queue_popper.hpp🔗

Namespaces🔗

Name
iox
iox::popo

Classes🔗

Name
class iox::popo::ChunkQueuePopper
The ChunkQueuePopper is the low layer building block to receive SharedChunks. It follows a first-in-first-out principle. Together with the ChunkDistributor and the ChunkQueuePusher, the ChunkQueuePopper builds the infrastructure to exchange memory chunks between different data producers and consumers that could be located in different processes. A ChunkQueuePopper is used to build elements of higher abstraction layers that also do memory managemet and provide an API towards the real user.

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_CHUNK_QUEUE_POPPER_HPP
#define IOX_POSH_POPO_BUILDING_BLOCKS_CHUNK_QUEUE_POPPER_HPP

#include "iceoryx_posh/internal/mepoo/shared_chunk.hpp"
#include "iceoryx_posh/internal/popo/building_blocks/chunk_queue_data.hpp"
#include "iceoryx_posh/internal/popo/building_blocks/condition_notifier.hpp"
#include "iceoryx_utils/cxx/helplets.hpp"
#include "iceoryx_utils/cxx/optional.hpp"

namespace iox
{
namespace popo
{
template <typename ChunkQueueDataType>
class ChunkQueuePopper
{
  public:
    using MemberType_t = ChunkQueueDataType;

    explicit ChunkQueuePopper(cxx::not_null<MemberType_t* const> chunkQueueDataPtr) noexcept;

    ChunkQueuePopper(const ChunkQueuePopper& other) = delete;
    ChunkQueuePopper& operator=(const ChunkQueuePopper&) = delete;
    ChunkQueuePopper(ChunkQueuePopper&& rhs) = default;
    ChunkQueuePopper& operator=(ChunkQueuePopper&& rhs) = default;
    virtual ~ChunkQueuePopper() = default;

    cxx::optional<mepoo::SharedChunk> tryPop() noexcept;

    bool hasLostChunks() noexcept;

    bool empty() const noexcept;

    uint64_t size() noexcept;

    void setCapacity(const uint64_t newCapacity) noexcept;

    uint64_t getCurrentCapacity() const noexcept;

    uint64_t getMaximumCapacity() const noexcept;

    void clear() noexcept;

    void setConditionVariable(ConditionVariableData& conditionVariableDataRef,
                              const uint64_t notificationIndex) noexcept;

    void unsetConditionVariable() noexcept;

    bool isConditionVariableSet() const noexcept;

  protected:
    const MemberType_t* getMembers() const noexcept;
    MemberType_t* getMembers() noexcept;

  private:
    MemberType_t* m_chunkQueueDataPtr;
};

} // namespace popo
} // namespace iox

#include "iceoryx_posh/internal/popo/building_blocks/chunk_queue_popper.inl"

#endif // IOX_POSH_POPO_BUILDING_BLOCKS_CHUNK_QUEUE_POPPER_HPP

Updated on 17 June 2021 at 11:15:27 CEST