-
Notifications
You must be signed in to change notification settings - Fork 173
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
[Core] publisher config API #1561
Merged
Merged
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
22d15d1
new publisher config API first draft
rex-schilasky 1fc0e3d
Merge branch 'master' into feature/parameter-api-publisher
rex-schilasky 4462bd6
some publisher tests reactivated (layer depending or shm layer parame…
rex-schilasky 82c4269
person snd udp sample added
rex-schilasky d3a8b46
Merge branch 'master' into feature/parameter-api-publisher
rex-schilasky f3a58f3
person_snd_udp sample fixed
rex-schilasky 0ee1477
buffer count needs to be set after creation of shm writer
rex-schilasky be6cf11
CPublisher::Config used in all writers
rex-schilasky 5d14fc7
clang-tidy
rex-schilasky b57db88
pubsub tests reclustered (shm, udp, tcp)
rex-schilasky 991179d
more pubsub tests sorted out for shm only
rex-schilasky 010bbdf
publisher config separated
rex-schilasky 6818c2c
clang-tidy + PubConfig fixed
rex-schilasky eb93882
PubConfig -> Publisher::Configuration
rex-schilasky 0b4f932
improved documentation
rex-schilasky 37b6fdc
internal reader/writer map handling redesigned (one common map instea…
rex-schilasky 0f79cd1
renamings, layer info added to internal pub/sub maps
rex-schilasky c2970dd
atomic Initialization
rex-schilasky 1190753
Stop function introduced (former Destroy) to shutdown (publisher, sub…
rex-schilasky 18d98be
core_cpp_pubsub, TimeoutAcknowledgment timing changed (failed on GH a…
rex-schilasky 7804f09
changed naming activate to enable for shm, udp, tcp layer configuration
rex-schilasky 892c73f
clang-tidy
rex-schilasky 77eb296
memfile buffer number removed from writer attributes (can not be chan…
rex-schilasky d78c4d3
single component finalizing removed
rex-schilasky d0d034e
eCAL::Finalize() fixed (no more parameter)
rex-schilasky 90dd2da
cleanups
rex-schilasky b08bec3
fixed zero copy mode on/off logic
rex-schilasky File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
/* ========================= eCAL LICENSE ================================= | ||
* | ||
* Copyright (C) 2016 - 2019 Continental Corporation | ||
* | ||
* 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. | ||
* | ||
* ========================= eCAL LICENSE ================================= | ||
*/ | ||
|
||
/** | ||
* @file ecal_publisher_config.h | ||
* @brief eCAL publisher configuration | ||
* | ||
* This publisher configuration struct can be used to define the behavior of an eCAL publisher. Additional information on | ||
* selected configuration parameters: | ||
* | ||
* -------------------------------------------------------------------------------------------------------------- | ||
* Zero copy shared memory transport mode (SHM::Configuration::zero_copy_mode) | ||
* -------------------------------------------------------------------------------------------------------------- | ||
* | ||
* By default, the built-in shared memory layer is configured to make two memory copies | ||
* one on the publisher and one on the subscriber side. | ||
* | ||
* The intention of this implementation is to free the file as fast as possible after writing and reading | ||
* its content to allow other processes to access the content with minimal latency. The publisher and subscribers | ||
* are fully decoupled and can access their internal memory copy independently. | ||
* | ||
* If the zero copy mode is switched on no memory will be copied at all using the low level binary publish / subscribe API. | ||
* On publisher side the memory copy is exectuted into the opened memory file. On the subscriber side the user message | ||
* callback is called right after opening the memory file. A direct pointer to the memory payload is forwarded | ||
* and can be processed with no latency. The memory file will be closed after the user callback function | ||
* returned. | ||
* | ||
* The advantage of this configuration is a much higher performance for large payloads (> 1024 kB). | ||
* The disadvantage of this configuration is that in the time when the callback is executed the memory file | ||
* is blocked for other subscribers and for writing publishers too. Maybe this can be eliminated | ||
* by a better memory file read/write access implementation (lock free read) in future releases. | ||
* | ||
* Today, for specific scenarios (1:1 pub/sub connections with large payloads for example) this feature | ||
* can increase the performance remarkable. But please keep in mind to return from the message callback function | ||
* as fast as possible to not delay subsequent read/write access operations. | ||
* | ||
* By using the eCAL::CPayloadWriter API a full zero copy implementation is possible by providing separate methods | ||
* for the initialization and the modification of the memory file content (see CPayloadWriter documentation). | ||
* | ||
* | ||
* -------------------------------------------------------------------------------------------------------------- | ||
* Subscriber receive acknowledgement with timeout (SHM::Configuration::acknowledge_timeout_ms) | ||
* -------------------------------------------------------------------------------------------------------------- | ||
* | ||
* Most applications perform very well with the default behavior. If subscribers are too slow | ||
* to process incoming messages then the overall software architecture needs to be checked, software components | ||
* need to be optimized or parallelized. | ||
* | ||
* There may still be cases where it could make sense to synchronize the transfer of the payload from a publisher | ||
* to a subscriber by using an additional handshake event. This event is signaled by a subscriber back to the | ||
* sending publisher to confirm the complete payload transmission and the processed subscriber callback. | ||
* | ||
* The publisher will wait up to the specified timeout for the acknowledge signals of all connected subscribers | ||
* before sending new content. Finally that means the publishers CPublisher::Send API function call is now blocked | ||
* and will not return until all subscriber have read and processed their content or the timeout has been reached. | ||
* | ||
* | ||
* -------------------------------------------------------------------------------------------------------------- | ||
* Number of handled memory files (SHM::Configuration::memfile_buffer_count) | ||
* -------------------------------------------------------------------------------------------------------------- | ||
* | ||
* By default, each publisher creates one memory file to distribute its payload to the subscribers. Since eCAL does not | ||
* currently support a rw lock synchronisation mechanism for interprocess communication, reading subscribers are blocking | ||
* the memory file and thus are preventing a publisher from writing the next payload into the file. | ||
* | ||
* This blocking behavior can be mitigated by using multiple memory files per publisher/subscriber connection. These memory | ||
* files are then written in a kind of ring buffer. | ||
* | ||
* The disadvantage of this setting (memfile_buffer_count > 1) is the higher consumption of resources (memory files, events..) | ||
* | ||
**/ | ||
|
||
#pragma once | ||
|
||
#include <ecal/ecal_tlayer.h> | ||
|
||
#include <cstddef> | ||
|
||
namespace eCAL | ||
{ | ||
namespace Publisher | ||
{ | ||
namespace SHM | ||
{ | ||
struct ECAL_API Configuration | ||
{ | ||
bool enable = false; //!< enable layer | ||
bool zero_copy_mode = false; //!< enable zero copy shared memory transport mode | ||
int acknowledge_timeout_ms = 0; /*!< force connected subscribers to send acknowledge event after processing the message | ||
the publisher send call is blocked on this event with this timeout (0 == no handshake) */ | ||
size_t memfile_min_size_bytes = 4096; //!< default memory file size for new publisher | ||
size_t memfile_reserve_percent = 50; //!< dynamic file size reserve before recreating memory file if topic size changes | ||
size_t memfile_buffer_count = 1; //!< maximum number of used buffers (needs to be greater than 1, default = 1) | ||
}; | ||
} | ||
|
||
namespace UDP | ||
{ | ||
struct ECAL_API Configuration | ||
{ | ||
bool enable = false; //!< enable layer | ||
bool loopback = false; //!< enable to receive udp messages on the same local machine | ||
int sndbuf_size_bytes = (5*1024*1024); //!< udp send buffer size in bytes (default 5MB) | ||
}; | ||
} | ||
|
||
namespace TCP | ||
{ | ||
struct ECAL_API Configuration | ||
{ | ||
bool enable = false; //!< enable layer | ||
}; | ||
} | ||
|
||
struct ECAL_API Configuration | ||
{ | ||
Configuration(); | ||
|
||
SHM::Configuration shm; | ||
UDP::Configuration udp; | ||
TCP::Configuration tcp; | ||
|
||
bool share_topic_type = true; //!< share topic type via registration | ||
bool share_topic_description = true; //!< share topic description via registration | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
we should discuss if we still support this for ecal 6. Also do we need to distinguish between type and descriptor? maybe only allow to switch of descriptor? (but not in this PR)