iceoryx_doc  1.0.1
chunk_queue_popper.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_CHUNK_QUEUE_POPPER_HPP
18 #define IOX_POSH_POPO_BUILDING_BLOCKS_CHUNK_QUEUE_POPPER_HPP
19 
20 #include "iceoryx_posh/internal/mepoo/shared_chunk.hpp"
21 #include "iceoryx_posh/internal/popo/building_blocks/chunk_queue_data.hpp"
22 #include "iceoryx_posh/internal/popo/building_blocks/condition_notifier.hpp"
23 #include "iceoryx_utils/cxx/helplets.hpp"
24 #include "iceoryx_utils/cxx/optional.hpp"
25 
26 namespace iox
27 {
28 namespace popo
29 {
35 template <typename ChunkQueueDataType>
37 {
38  public:
39  using MemberType_t = ChunkQueueDataType;
40 
41  explicit ChunkQueuePopper(cxx::not_null<MemberType_t* const> chunkQueueDataPtr) noexcept;
42 
43  ChunkQueuePopper(const ChunkQueuePopper& other) = delete;
44  ChunkQueuePopper& operator=(const ChunkQueuePopper&) = delete;
45  ChunkQueuePopper(ChunkQueuePopper&& rhs) = default;
46  ChunkQueuePopper& operator=(ChunkQueuePopper&& rhs) = default;
47  virtual ~ChunkQueuePopper() = default;
48 
51  cxx::optional<mepoo::SharedChunk> tryPop() noexcept;
52 
55  bool hasLostChunks() noexcept;
56 
59  bool empty() const noexcept;
60 
64  uint64_t size() noexcept;
65 
70  void setCapacity(const uint64_t newCapacity) noexcept;
71 
74  uint64_t getCurrentCapacity() const noexcept;
75 
78  uint64_t getMaximumCapacity() const noexcept;
79 
81  void clear() noexcept;
82 
85  void setConditionVariable(ConditionVariableData& conditionVariableDataRef,
86  const uint64_t notificationIndex) noexcept;
87 
89  void unsetConditionVariable() noexcept;
90 
93  bool isConditionVariableSet() const noexcept;
94 
95  protected:
96  const MemberType_t* getMembers() const noexcept;
97  MemberType_t* getMembers() noexcept;
98 
99  private:
100  MemberType_t* m_chunkQueueDataPtr;
101 };
102 
103 } // namespace popo
104 } // namespace iox
105 
106 #include "iceoryx_posh/internal/popo/building_blocks/chunk_queue_popper.inl"
107 
108 #endif // IOX_POSH_POPO_BUILDING_BLOCKS_CHUNK_QUEUE_POPPER_HPP
The ChunkQueuePopper is the low layer building block to receive SharedChunks. It follows a first-in-f...
Definition: chunk_queue_popper.hpp:37
void unsetConditionVariable() noexcept
Detaches a condition variable.
Definition: chunk_queue_popper.inl:137
void clear() noexcept
clear the queue
Definition: chunk_queue_popper.inl:117
uint64_t getCurrentCapacity() const noexcept
get the current capacity of the queue.
Definition: chunk_queue_popper.inl:105
bool empty() const noexcept
pop a chunk from the chunk queue
Definition: chunk_queue_popper.inl:87
uint64_t getMaximumCapacity() const noexcept
get the maximum capacity of the queue.
Definition: chunk_queue_popper.inl:111
bool hasLostChunks() noexcept
check if chunks were lost and reset flag
Definition: chunk_queue_popper.inl:76
void setConditionVariable(ConditionVariableData &conditionVariableDataRef, const uint64_t notificationIndex) noexcept
Attaches a condition variable.
Definition: chunk_queue_popper.inl:127
uint64_t size() noexcept
get the current size of the queue. Caution, another thread can have changed the size just after readi...
Definition: chunk_queue_popper.inl:93
cxx::optional< mepoo::SharedChunk > tryPop() noexcept
pop a chunk from the chunk queue
Definition: chunk_queue_popper.inl:48
void setCapacity(const uint64_t newCapacity) noexcept
set the capacity of the queue
Definition: chunk_queue_popper.inl:99
bool isConditionVariableSet() const noexcept
Returns the information whether a condition variable is attached.
Definition: chunk_queue_popper.inl:146
Definition: service_description.hpp:29
Definition: condition_variable_data.hpp:31