-
Notifications
You must be signed in to change notification settings - Fork 403
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Iox #25 chunk receiver building block #84
Changes from 6 commits
052f86e
5a9fdc7
33548dd
a943543
dd4d8a6
0dd4f60
dfbfa43
1e48520
db55440
41acea4
0d51b36
472aa97
ff74def
f8b98da
2b05e87
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,8 +29,6 @@ namespace iox | |
{ | ||
namespace popo | ||
{ | ||
struct ChunkQueueData; | ||
|
||
Comment on lines
-32
to
-33
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice catch! |
||
class ThreadSafePolicy | ||
{ | ||
public: // needs to be public since we want to use std::lock_guard | ||
|
@@ -72,12 +70,12 @@ struct ChunkDistributorData : public LockingPolicy | |
using lockGuard_t = std::lock_guard<ChunkDistributorData<MaxQueues, LockingPolicy>>; | ||
|
||
ChunkDistributorData(uint64_t historyCapacity = 0u) noexcept | ||
: m_historyCapacity(algorithm::min(historyCapacity, MAX_SENDER_SAMPLE_HISTORY_CAPACITY)) | ||
: m_historyCapacity(algorithm::min(historyCapacity, MAX_HISTORY_CAPACITY_OF_CHUNK_DISTRIBUTOR)) | ||
{ | ||
if (m_historyCapacity != historyCapacity) | ||
{ | ||
LogWarn() << "Chunk history too large, reducing from " << historyCapacity << " to " | ||
<< MAX_SENDER_SAMPLE_HISTORY_CAPACITY; | ||
<< MAX_HISTORY_CAPACITY_OF_CHUNK_DISTRIBUTOR; | ||
} | ||
} | ||
|
||
|
@@ -90,8 +88,8 @@ struct ChunkDistributorData : public LockingPolicy | |
/// When to store a SharedChunk and when the included ChunkManagement must be used? | ||
/// If we would make the ChunkDistributor lock-free, can we than extend the UsedChunkList to | ||
/// be like a ring buffer and use this for the history? This would be needed to be able to safely cleanup | ||
using SampleHistoryContainer_t = cxx::vector<mepoo::SharedChunk, MAX_SENDER_SAMPLE_HISTORY_CAPACITY>; | ||
SampleHistoryContainer_t m_sampleHistory; | ||
using HistoryContainer_t = cxx::vector<mepoo::SharedChunk, MAX_HISTORY_CAPACITY_OF_CHUNK_DISTRIBUTOR>; | ||
HistoryContainer_t m_history; | ||
}; | ||
|
||
} // namespace popo | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
// Copyright (c) 2020 by Robert Bosch GmbH. 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. | ||
|
||
#ifndef IOX_POSH_POPO_CHUNK_RECEIVER_HPP_ | ||
#define IOX_POSH_POPO_CHUNK_RECEIVER_HPP_ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As we decided to switch to include guards (#30), we can keep them here. Isn't the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought I use them here as we decided to use them again. But we haven't defined a rule for them yet, or? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nope there's no rule yet. Let's define it with #30 |
||
|
||
#include "iceoryx_posh/internal/popo/building_blocks/chunk_queue.hpp" | ||
#include "iceoryx_posh/internal/popo/building_blocks/chunk_receiver_data.hpp" | ||
#include "iceoryx_posh/mepoo/chunk_header.hpp" | ||
#include "iceoryx_utils/cxx/expected.hpp" | ||
#include "iceoryx_utils/cxx/optional.hpp" | ||
|
||
namespace iox | ||
{ | ||
namespace popo | ||
{ | ||
enum class ChunkReceiverError | ||
{ | ||
TOO_MANY_CHUNKS_HELD_IN_PARALLEL | ||
}; | ||
|
||
/// @brief The ChunkReceiver is a building block of the shared memory communication infrastructure. It extends | ||
/// the functionality of a ChunkQueue with the abililty to pass chunks to the user side (user process). | ||
/// Together with the ChunkSender, they are the next abstraction layer on top of ChunkDistributor and ChunkQueue. The | ||
/// ChunkRceiver holds the ownership of the SharedChunks and does a bookkeeping which chunks are currently passed to the | ||
/// user side. | ||
class ChunkReceiver : public ChunkQueue | ||
{ | ||
public: | ||
using MemberType_t = ChunkReceiverData; | ||
|
||
ChunkReceiver(MemberType_t* const chunkReceiverDataPtr) noexcept; | ||
|
||
ChunkReceiver(const ChunkReceiver& other) = delete; | ||
ChunkReceiver& operator=(const ChunkReceiver&) = delete; | ||
ChunkReceiver(ChunkReceiver&& rhs) = default; | ||
ChunkReceiver& operator=(ChunkReceiver&& rhs) = default; | ||
~ChunkReceiver() = default; | ||
|
||
/// @brief Tries to get the next received chunk. If there is a new one the ChunkHeader of this new chunk is received | ||
/// The ownerhip of the SharedChunk remains in the ChunkReceiver for being able to cleanup if the user process | ||
/// disappears | ||
/// @return optional that has a new chunk header or no value if there are no new chunks in the underlying queue, | ||
/// ChunkReceiverError on error | ||
cxx::expected<cxx::optional<const mepoo::ChunkHeader*>, ChunkReceiverError> get() noexcept; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, if there is no new chunk, you will get an empty optional without an error. Like a pop on an empty FiFo |
||
|
||
/// @brief Release a chunk that was obtained with get | ||
/// @param[in] chunkHeader, pointer to the ChunkHeader to free | ||
void release(const mepoo::ChunkHeader* chunkHeader) noexcept; | ||
|
||
/// @brief Release all the chunks that are currently held. Caution: Only call this if the user process is no more | ||
/// running E.g. This cleans up chunks that were held by a user process that died unexpectetly, for avoiding lost | ||
/// chunks in the system | ||
void releaseAll() noexcept; | ||
|
||
private: | ||
const MemberType_t* getMembers() const noexcept; | ||
MemberType_t* getMembers() noexcept; | ||
}; | ||
|
||
} // namespace popo | ||
} // namespace iox | ||
|
||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep fighting the trailing whitespaces :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doesn't your IDE automatically remove trailing whitespaces ... me starting IDE war and running away ;)