Skip to content

Commit

Permalink
review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
yellowhatter committed Dec 26, 2024
1 parent 8e8e4b8 commit 085771e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
8 changes: 5 additions & 3 deletions rmw_zenoh_cpp/src/detail/shm_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,22 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#ifdef RMW_ZENOH_BUILD_WITH_SHARED_MEMORY

#include <stdexcept>

#include "shm_context.hpp"

namespace rmw_zenoh_cpp
{
///=============================================================================
#ifdef RMW_ZENOH_BUILD_WITH_SHARED_MEMORY
ShmContext::ShmContext(size_t alloc_size, size_t msgsize_threshold)
: // Create Layout for provider's memory
// Provider's alignment will be 1 byte as we are going to make only 1-byte aligned allocations
// Provider's alignment will be 1 (=2^0) bytes as we are going to make only 1-byte aligned allocations
// TODO(yellowhatter): use zenoh_shm_message_size_threshold as base for alignment
shm_provider(zenoh::PosixShmProvider(zenoh::MemoryLayout(alloc_size, zenoh::AllocAlignment {0}))),
msgsize_threshold(msgsize_threshold)
{}
#endif
} // namespace rmw_zenoh_cpp

#endif
6 changes: 4 additions & 2 deletions rmw_zenoh_cpp/src/detail/shm_context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#ifdef RMW_ZENOH_BUILD_WITH_SHARED_MEMORY

#ifndef DETAIL__SHM_CONTEXT_HPP_
#define DETAIL__SHM_CONTEXT_HPP_

Expand All @@ -20,15 +22,15 @@
namespace rmw_zenoh_cpp
{
///=============================================================================
#ifdef RMW_ZENOH_BUILD_WITH_SHARED_MEMORY
struct ShmContext
{
zenoh::PosixShmProvider shm_provider;
size_t msgsize_threshold;

ShmContext(size_t alloc_size, size_t msgsize_threshold);
};
#endif
} // namespace rmw_zenoh_cpp

#endif // DETAIL__SHM_CONTEXT_HPP_

#endif
2 changes: 1 addition & 1 deletion rmw_zenoh_cpp/src/detail/zenoh_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ static const bool zenoh_shm_enabled_default = true;
static const char * zenoh_shm_alloc_size_envar = "ZENOH_SHM_ALLOC_SIZE";
static const size_t zenoh_shm_alloc_size_default = 1 * 1024 * 1024;
static const char * zenoh_shm_message_size_threshold_envar = "ZENOH_SHM_MESSAGE_SIZE_THRESHOLD";
static const size_t zenoh_shm_message_size_threshold_default = 2 * 1024;
static const size_t zenoh_shm_message_size_threshold_default = 1; //2 * 1024;
#endif

std::optional<zenoh::Config> _get_z_config(
Expand Down

0 comments on commit 085771e

Please sign in to comment.