diff --git a/.cirrus.yml b/.cirrus.yml
index fd2b7d838..a5154d4c5 100644
--- a/.cirrus.yml
+++ b/.cirrus.yml
@@ -271,15 +271,4 @@ macos_aarch64_stable_debug_task:
- rustup component add clippy rustfmt
set_toolchain_script: rustup default stable
<<: *IOX2_CARGO_FMT_AND_CLIPPY
- <<: *IOX2_COMMON_BUILD_DEBUG
- test_script:
- - cargo test -p iceoryx2-pal-concurrency-sync
- -p iceoryx2-pal-posix
- -p iceoryx2-bb-container
- -p iceoryx2-bb-elementary
- -p iceoryx2-bb-lock-free
- -p iceoryx2-bb-log
- -p iceoryx2-bb-memory
- -p iceoryx2-bb-system-types
- -p iceoryx2-bb-testing
- --lib --bins --tests --no-fail-fast
+ <<: *IOX2_COMMON_BUILD_AND_TEST_DEBUG
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index e69de29bb..c56d93e98 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -0,0 +1,45 @@
+# Contributing to Eclipse iceoryx2
+
+ 1. Every new contributor must sign the
+ [Eclipse Contributor Agreement (ECA)](https://www.eclipse.org/legal/ECA.php)
+ first.
+ 2. Before you start to work, please create an issue first.
+ 3. Create a branch with the prefix `iox2-$ISSUE_NUMBER$`.
+ 4. Every file requires this copyright header.
+
+ ```
+ // Copyright (c) 2023 Contributors to the Eclipse Foundation
+ //
+ // See the NOTICE file(s) distributed with this work for additional
+ // information regarding copyright ownership.
+ //
+ // This program and the accompanying materials are made available under the
+ // terms of the Apache Software License 2.0 which is available at
+ // https://www.apache.org/licenses/LICENSE-2.0, or the MIT license
+ // which is available at https://opensource.org/licenses/MIT.
+ //
+ // SPDX-License-Identifier: Apache-2.0 OR MIT
+ ```
+
+ 5. Every commit must have the prefix `[#$ISSUE_NUMBER$]`.
+ 6. When the work is done, please add your changes to the release notes in
+ `doc/release-notes/iceoryx2-unreleased.md`.
+ 7. Create a pull request.
+ 8. (optional) If you are a new contributor we would love to show our gratitude
+ for your support so please add yourself at the end of `README.md`.
+ The entry template looks like this:
+
+ ```html
+
+
+
+ $FIRST_NAME$ »$COOL_NICK_NAME$« $LAST_NAME$
+ ```
+
+ **Notes:**
+ * The `$FIRST_NAME »$COOL_NICK_NAME$« $LAST_NAME$` is a suggestion but it can
+ be whatever you feel comfortable with.
+ * You can obtain the ID of your profile picture by clicking on your profile
+ icon on the top right, selecting `Your profile` and then right-clicking on
+ your profile picture and selecting `Copy image address`. The last number in
+ the URL is the ID of your profile picture.
diff --git a/README.md b/README.md
index 0497a3a64..3c6ba0a13 100644
--- a/README.md
+++ b/README.md
@@ -260,7 +260,7 @@ The support levels can be adjusted when required.
| Linux (x86_64) | done | tier 2 | tier 1 |
| Linux (aarch64) | done | tier 2 | tier 1 |
| Linux (32-bit) | in-progress | tier 3 | tier 1 |
-| Mac OS | in-progress | tier 3 | tier 2 |
+| Mac OS | done | tier 2 | tier 2 |
| QNX | planned | - | tier 1 |
| WatchOS | planned | - | tier 2 |
| Windows | done | tier 2 | tier 2 |
diff --git a/ROADMAP.md b/ROADMAP.md
index cbc16d9e9..12b4e5fd5 100644
--- a/ROADMAP.md
+++ b/ROADMAP.md
@@ -7,6 +7,19 @@
* [ ] `#![no_std]` on `stable` on all tier 1 platforms
* [ ] completely dynamic setup with dynamic shared memory
+## Shared Memory Container & Types
+
+* [ ] Make `iceoryx2_bb_container` public with announcement
+* [ ] Create and document dynamic size container concept for shared memory and apply it
+ to all existing containers: `ByteString`, `Vec`, `Queue`
+ * Open Question: How can these containers be cloned, copied?
+* [ ] Introduce additional containers: `HashMap`, `Tree`, `Set`, `List`
+* [ ] Introduce elementary types, look into: `simple-si-units` crate
+ * Add types like: memory size, percentage, strict percentage (0..100), data throughput, resolution
+ (further types found in informatics)
+* [ ] Add `derive` proc macro to ensure that only shm compatible types can be
+ transferred via zero-copy
+
## Language Bindings
* [ ] C
@@ -59,6 +72,7 @@
* [ ] Zero-copy GPU communication with Cuda, NvSci, Vulkan
* [ ] Zero-copy across hypervisor partitions
* [ ] Zero-copy via QEMU ivshmem:
+* [ ] dmabuf support, see: https://blaztinn.gitlab.io/post/dmabuf-texture-sharing/
* [ ] Support dynamic sized types in a memory efficient manner
* Buddy allocator for sender data-segment
* Introduce runtime fixed-size types
@@ -77,7 +91,7 @@
* [ ] Android
* [x] Linux
* [x] Windows
-* [ ] Mac Os
+* [x] Mac Os
* [ ] iOS
* [ ] WatchOS
* [x] FreeBSD
@@ -128,3 +142,7 @@
* simple use case: pub/sub + event to notify subscriber to notify sample send
* would reduce error handling: connect to service with wrong messaging pattern
* [ ] Implement Resizable SharedMemoryConcept that is able to extend the shared memory by adding additional posix shared memory objects
+
+## Integration Into Other Projects
+
+* [ ] Maybe Hyprland
diff --git a/doc/release-notes/iceoryx2-unreleased.md b/doc/release-notes/iceoryx2-unreleased.md
index c21667e6c..2632b3cb0 100644
--- a/doc/release-notes/iceoryx2-unreleased.md
+++ b/doc/release-notes/iceoryx2-unreleased.md
@@ -1,20 +1,22 @@
# iceoryx2 v?.?.?
-## [vx.x.x](https://github.com/larry-robotics/iceoryx2/tree/vx.x.x) (xxxx-xx-xx)
+## [vx.x.x](https://github.com/eclipse-iceoryx/iceoryx2/tree/vx.x.x) (xxxx-xx-xx)
-[Full Changelog](https://github.com/larry-robotics/iceoryx2/compare/vx.x.x...vx.x.x)
+[Full Changelog](https://github.com/eclipse-iceoryx/iceoryx2/compare/vx.x.x...vx.x.x)
### Features
- * Example [#1](https://github.com/larry-robotics/iceoryx2/issues/1)
+ * MacOS Platform support [#51](https://github.com/eclipse-iceoryx/iceoryx2/issues/51)
+ * Services with the same name for different messaging patterns are supported [#16](https://github.com/eclipse-iceoryx/iceoryx2/issues/16)
### Bugfixes
- * Example [#1](https://github.com/larry-robotics/iceoryx2/issues/1)
+ * Fix undefined behavior in `FixedSizeByteString::new_unchecked` [#61](https://github.com/eclipse-iceoryx/iceoryx2/issues/61)
+ * Fix suffix of static config [#66](https://github.com/eclipse-iceoryx/iceoryx2/issues/66)
### Refactoring
- * Example [#1](https://github.com/larry-robotics/iceoryx2/issues/1)
+ * Example [#1](https://github.com/eclipse-iceoryx/iceoryx2/issues/1)
### Workflow
@@ -22,7 +24,9 @@
### New API features
- * Example [#1](https://github.com/larry-robotics/iceoryx2/issues/1)
+ * Add `FixedSizeByteString::from_bytes_truncated` [#56](https://github.com/eclipse-iceoryx/iceoryx2/issues/56)
+ * Add `Deref`, `DerefMut`, `Clone`, `Eq`, `PartialEq` and `extend_from_slice` to (FixedSize)Vec [#58](https://github.com/eclipse-iceoryx/iceoryx2/issues/58)
+ * `MessagingPattern` implements `Display` [#64](https://github.com/eclipse-iceoryx/iceoryx2/issues/64)
### API Breaking Changes
diff --git a/iceoryx2-bb/container/src/byte_string.rs b/iceoryx2-bb/container/src/byte_string.rs
index 2f1fb638c..db9e8b937 100644
--- a/iceoryx2-bb/container/src/byte_string.rs
+++ b/iceoryx2-bb/container/src/byte_string.rs
@@ -207,23 +207,12 @@ impl FixedSizeByteString {
///
/// * `bytes` len must be smaller or equal than [`FixedSizeByteString::capacity()`]
///
- pub const unsafe fn new_unchecked(bytes: &[u8]) -> Self {
+ pub unsafe fn new_unchecked(bytes: &[u8]) -> Self {
if CAPACITY < bytes.len() {
panic!("Insufficient capacity to store bytes.");
}
- let mut new_self = Self::new();
- new_self.len = bytes.len();
- std::ptr::copy(
- bytes.as_ptr(),
- new_self.data.as_ptr() as *mut u8,
- bytes.len(),
- );
-
- let zero = 0u8;
- std::ptr::copy(&zero, new_self.data.as_ptr().add(bytes.len()) as *mut u8, 1);
-
- new_self
+ Self::from_bytes_truncated(bytes)
}
/// Creates a new [`FixedSizeByteString`] from a byte slice
@@ -237,6 +226,22 @@ impl FixedSizeByteString {
Ok(new_self)
}
+ /// Creates a new [`FixedSizeByteString`] from a byte slice. If the byte slice does not fit
+ /// into the [`FixedSizeByteString`] it will be truncated.
+ pub fn from_bytes_truncated(bytes: &[u8]) -> Self {
+ let mut new_self = Self::new();
+ new_self.len = std::cmp::min(bytes.len(), CAPACITY);
+ for (i, byte) in bytes.iter().enumerate().take(new_self.len) {
+ new_self.data[i].write(*byte);
+ }
+
+ if new_self.len < CAPACITY {
+ new_self.data[new_self.len].write(0);
+ }
+
+ new_self
+ }
+
/// Creates a new byte string from a given null-terminated string
///
/// # Safety
diff --git a/iceoryx2-bb/container/src/semantic_string.rs b/iceoryx2-bb/container/src/semantic_string.rs
index ea3abf34f..a1400fdcd 100644
--- a/iceoryx2-bb/container/src/semantic_string.rs
+++ b/iceoryx2-bb/container/src/semantic_string.rs
@@ -295,7 +295,7 @@ macro_rules! semantic_string {
}
impl $string_name {
- pub const unsafe fn new_unchecked(bytes: &[u8]) -> Self {
+ pub unsafe fn new_unchecked(bytes: &[u8]) -> Self {
Self {
value: iceoryx2_bb_container::byte_string::FixedSizeByteString::new_unchecked(bytes),
}
diff --git a/iceoryx2-bb/container/src/vec.rs b/iceoryx2-bb/container/src/vec.rs
index 132f21518..5b2bfa21c 100644
--- a/iceoryx2-bb/container/src/vec.rs
+++ b/iceoryx2-bb/container/src/vec.rs
@@ -64,6 +64,8 @@
use std::{
alloc::Layout,
mem::MaybeUninit,
+ ops::Deref,
+ ops::DerefMut,
sync::atomic::{AtomicBool, Ordering},
};
@@ -136,6 +138,42 @@ impl RelocatableContainer for Vec {
}
}
+impl Deref for Vec {
+ type Target = [T];
+
+ fn deref(&self) -> &Self::Target {
+ self.verify_init(&format!("Vec<{}>::push()", std::any::type_name::()));
+ unsafe { core::slice::from_raw_parts((*self.data_ptr.as_ptr()).as_ptr(), self.len) }
+ }
+}
+
+impl DerefMut for Vec {
+ fn deref_mut(&mut self) -> &mut Self::Target {
+ self.verify_init(&format!("Vec<{}>::push()", std::any::type_name::()));
+ unsafe {
+ core::slice::from_raw_parts_mut((*self.data_ptr.as_mut_ptr()).as_mut_ptr(), self.len)
+ }
+ }
+}
+
+impl PartialEq for Vec {
+ fn eq(&self, other: &Self) -> bool {
+ if other.len() != self.len() {
+ return false;
+ }
+
+ for i in 0..self.len() {
+ if other[i] != self[i] {
+ return false;
+ }
+ }
+
+ true
+ }
+}
+
+impl Eq for Vec {}
+
impl Vec {
fn verify_init(&self, source: &str) {
if !self
@@ -212,6 +250,27 @@ impl Vec {
self.len += 1;
}
+ /// Append all elements from other via [`Clone`].
+ ///
+ /// # Safety
+ ///
+ /// * Only use this method when [`Vec::init()`] was called before
+ ///
+ pub unsafe fn extend_from_slice(&mut self, other: &[T]) -> bool
+ where
+ T: Clone,
+ {
+ if self.capacity < self.len + other.len() {
+ return false;
+ }
+
+ for element in other {
+ self.push_unchecked(element.clone());
+ }
+
+ true
+ }
+
/// Removes the last element of the vector and returns it to the user. If the vector is empty
/// it returns [`None`].
///
@@ -249,62 +308,6 @@ impl Vec {
value.assume_init()
}
-
- /// Returns a reference to the element at the specified index. If the index is out of bounds it
- /// returns [`None`].
- ///
- /// # Safety
- ///
- /// * Only use this method when [`Vec::init()`] was called before
- ///
- pub unsafe fn get(&self, index: usize) -> Option<&T> {
- if self.len <= index {
- None
- } else {
- self.verify_init(&format!("Vec<{}>::get()", std::any::type_name::()));
- Some(self.get_unchecked(index))
- }
- }
-
- /// Returns a reference to the element at the specified index. The user has to ensure that the
- /// index is present in the vector otherwise it leads to undefined behavior.
- ///
- /// # Safety
- ///
- /// * Only use this method when [`Vec::init()`] was called before
- /// * The index must be not out of bounds
- ///
- pub unsafe fn get_unchecked(&self, index: usize) -> &T {
- &*(*self.data_ptr.as_ptr().add(index)).as_ptr()
- }
-
- /// Returns a mutable reference to the element at the specified index. If the index is out of
- /// bounds it returns [`None`].
- ///
- /// # Safety
- ///
- /// * Only use this method when [`Vec::init()`] was called before
- ///
- pub unsafe fn get_mut(&mut self, index: usize) -> Option<&mut T> {
- if self.len <= index {
- None
- } else {
- self.verify_init(&format!("Vec<{}>::get_mut()", std::any::type_name::()));
- Some(self.get_unchecked_mut(index))
- }
- }
-
- /// Returns a mutable reference to the element at the specified index. The user has to ensure
- /// that the index is present in the vector otherwise it leads to undefined behavior.
- ///
- /// # Safety
- ///
- /// * Only use this method when [`Vec::init()`] was called before
- /// * The index must be not out of bounds
- ///
- pub unsafe fn get_unchecked_mut(&mut self, index: usize) -> &mut T {
- &mut *(*self.data_ptr.as_mut_ptr().add(index)).as_mut_ptr()
- }
}
/// Relocatable vector with compile time fixed size capacity. In contrast to its counterpart the
@@ -330,6 +333,36 @@ impl Default for FixedSizeVec {
}
}
+impl Deref for FixedSizeVec {
+ type Target = [T];
+
+ fn deref(&self) -> &Self::Target {
+ self.state.deref()
+ }
+}
+
+impl DerefMut for FixedSizeVec {
+ fn deref_mut(&mut self) -> &mut Self::Target {
+ self.state.deref_mut()
+ }
+}
+
+impl PartialEq for FixedSizeVec {
+ fn eq(&self, other: &Self) -> bool {
+ self.state.eq(&other.state)
+ }
+}
+
+impl Eq for FixedSizeVec {}
+
+impl Clone for FixedSizeVec {
+ fn clone(&self) -> Self {
+ let mut new_self = Self::new();
+ new_self.extend_from_slice(self.deref());
+ new_self
+ }
+}
+
unsafe impl Send for FixedSizeVec {}
unsafe impl Sync for FixedSizeVec {}
@@ -373,6 +406,14 @@ impl FixedSizeVec {
unsafe { self.state.fill(value) }
}
+ /// Append all elements from other via [`Clone`].
+ pub fn extend_from_slice(&mut self, other: &[T]) -> bool
+ where
+ T: Clone,
+ {
+ unsafe { self.state.extend_from_slice(other) }
+ }
+
/// Removes the last element of the vector and returns it to the user. If the vector is empty
/// it returns [`None`].
pub fn pop(&mut self) -> Option {
@@ -383,38 +424,4 @@ impl FixedSizeVec {
pub fn clear(&mut self) {
unsafe { self.state.clear() }
}
-
- /// Returns a reference to the element at the specified index. If the index is out of bounds it
- /// returns [`None`].
- pub fn get(&self, index: usize) -> Option<&T> {
- unsafe { self.state.get(index) }
- }
-
- /// Returns a reference to the element at the specified index. The user has to ensure that the
- /// index is present in the vector otherwise it leads to undefined behavior.
- ///
- /// # Safety
- ///
- /// * The index must be not out of bounds
- ///
- pub unsafe fn get_unchecked(&self, index: usize) -> &T {
- unsafe { self.state.get_unchecked(index) }
- }
-
- /// Returns a mutable reference to the element at the specified index. If the index is out of
- /// bounds it returns [`None`].
- pub fn get_mut(&mut self, index: usize) -> Option<&mut T> {
- unsafe { self.state.get_mut(index) }
- }
-
- /// Returns a mutable reference to the element at the specified index. The user has to ensure
- /// that the index is present in the vector otherwise it leads to undefined behavior.
- ///
- /// # Safety
- ///
- /// * The index must be not out of bounds
- ///
- pub unsafe fn get_unchecked_mut(&mut self, index: usize) -> &mut T {
- unsafe { self.state.get_unchecked_mut(index) }
- }
}
diff --git a/iceoryx2-bb/container/tests/byte_string_tests.rs b/iceoryx2-bb/container/tests/byte_string_tests.rs
index 0e58d6efd..1c1e9b633 100644
--- a/iceoryx2-bb/container/tests/byte_string_tests.rs
+++ b/iceoryx2-bb/container/tests/byte_string_tests.rs
@@ -47,19 +47,40 @@ fn fixed_size_byte_string_from_bytes_works() {
assert_that!(sut.pop(), eq Some(b'd'));
}
+#[test]
+fn fixed_size_byte_string_from_bytes_truncated_works() {
+ let sut = Sut::from_bytes(b"bonjour world");
+ assert_that!(sut, is_ok);
+ let mut sut = sut.unwrap();
+
+ assert_that!(sut, is_not_empty);
+ assert_that!(sut.is_full(), eq false);
+ assert_that!(sut, len 13);
+ assert_that!(sut, eq b"bonjour world");
+ assert_that!(sut, ne b"bonjour world! woo");
+ assert_that!(sut.as_bytes(), eq b"bonjour world");
+ assert_that!(sut.as_mut_bytes(), eq b"bonjour world");
+ assert_that!(sut.as_bytes_with_nul(), eq b"bonjour world\0");
+ assert_that!(sut.pop(), eq Some(b'd'));
+}
+
#[test]
fn fixed_size_byte_string_from_byte_slice_works() {
- let mut sut = Sut::from(b"hello world!");
+ let sut = FixedSizeByteString::<5>::from_bytes_truncated(b"hell");
assert_that!(sut, is_not_empty);
assert_that!(sut.is_full(), eq false);
- assert_that!(sut, len 12);
- assert_that!(sut, eq b"hello world!");
- assert_that!(sut, ne b"hello world! woo");
- assert_that!(sut.as_bytes(), eq b"hello world!");
- assert_that!(sut.as_mut_bytes(), eq b"hello world!");
- assert_that!(sut.as_bytes_with_nul(), eq b"hello world!\0");
- assert_that!(sut.pop(), eq Some(b'!'));
+ assert_that!(sut, len 4);
+ assert_that!(sut, eq b"hell");
+ assert_that!(sut.as_bytes_with_nul(), eq b"hell\0");
+
+ let sut = FixedSizeByteString::<5>::from_bytes_truncated(b"hello world");
+
+ assert_that!(sut, is_not_empty);
+ assert_that!(sut.is_full(), eq true);
+ assert_that!(sut, len 5);
+ assert_that!(sut, eq b"hello");
+ assert_that!(sut.as_bytes_with_nul(), eq b"hello\0");
}
#[test]
diff --git a/iceoryx2-bb/container/tests/vec_tests.rs b/iceoryx2-bb/container/tests/vec_tests.rs
index d2c3d2d4a..72b09a159 100644
--- a/iceoryx2-bb/container/tests/vec_tests.rs
+++ b/iceoryx2-bb/container/tests/vec_tests.rs
@@ -84,8 +84,8 @@ fn vec_push_pop_works_with_uninitialized_memory() {
assert_that!(sut.is_full(), eq true);
for i in 0..sut.capacity() {
- assert_that!(unsafe { *sut.get(i).unwrap() }, eq i * 2 + 3);
- assert_that!(unsafe { *sut.get_mut(i).unwrap() }, eq i * 2 + 3);
+ assert_that!(*sut.get(i).unwrap(), eq i * 2 + 3);
+ assert_that!(*sut.get_mut(i).unwrap(), eq i * 2 + 3);
assert_that!(unsafe { *sut.get_unchecked(i) }, eq i * 2 + 3);
assert_that!(unsafe { *sut.get_unchecked_mut(i) }, eq i * 2 + 3);
}
@@ -151,3 +151,49 @@ fn fixed_size_vec_valid_after_move() {
assert_that!(result, eq Some((sut2.capacity() - i - 1) * 2 + 3));
}
}
+
+#[test]
+fn fixed_size_vec_eq_works() {
+ let create_vec = |n| {
+ let mut sut = Sut::new();
+ for i in 0..n {
+ sut.push(4 * i + 3);
+ }
+ sut
+ };
+
+ let vec1 = create_vec(SUT_CAPACITY - 2);
+ let vec2 = create_vec(SUT_CAPACITY - 1);
+ let vec3 = create_vec(SUT_CAPACITY);
+
+ assert_that!(Sut::new() == Sut::new(), eq true);
+
+ assert_that!(vec1 == vec1, eq true);
+ assert_that!(vec1 == vec2, eq false);
+ assert_that!(vec1 == vec3, eq false);
+ assert_that!(vec1 == Sut::new(), eq false);
+
+ assert_that!(vec2 == vec1, eq false);
+ assert_that!(vec2 == vec2, eq true);
+ assert_that!(vec2 == vec3, eq false);
+ assert_that!(vec2 == Sut::new(), eq false);
+
+ assert_that!(vec3 == vec1, eq false);
+ assert_that!(vec3 == vec2, eq false);
+ assert_that!(vec3 == vec3, eq true);
+ assert_that!(vec3 == Sut::new(), eq false);
+}
+
+#[test]
+fn fixed_size_vec_clone_works() {
+ let mut sut = Sut::new();
+ let sut1 = sut.clone();
+ for i in 0..SUT_CAPACITY {
+ sut.push(8 * i + 6);
+ }
+
+ let sut2 = sut.clone();
+
+ assert_that!(Sut::new() == sut1, eq true);
+ assert_that!(sut == sut2, eq true);
+}
diff --git a/iceoryx2-bb/posix/src/condition_variable.rs b/iceoryx2-bb/posix/src/condition_variable.rs
index f84f35fc3..47420edd8 100644
--- a/iceoryx2-bb/posix/src/condition_variable.rs
+++ b/iceoryx2-bb/posix/src/condition_variable.rs
@@ -153,7 +153,7 @@ impl<'mutex, 'handle, T: Debug> From>
/// use iceoryx2_bb_posix::mutex::*;
///
///
-/// // create a condition variable which allows multiple predicates in wait_while nad
+/// // create a condition variable which allows multiple predicates in blocking_wait_while nad
/// // timed_wait_while
/// let mtx_handle = MutexHandle::::new();
/// let condvar = ConditionVariableBuilder::new()
@@ -237,7 +237,7 @@ impl ConditionVariableBuilder {
/// modified and used for triggering.
///
/// The condition variable can use
- /// multiple conditions in [`MultiConditionVariable::wait_while()`] and
+ /// multiple conditions in [`MultiConditionVariable::blocking_wait_while()`] and
/// [`MultiConditionVariable::timed_wait_while()`] but is only able to trigger all waiters.
pub fn create_multi_condition_variable(
self,
@@ -252,7 +252,7 @@ impl ConditionVariableBuilder {
///
/// The condition variable has one fixed
/// condition which has to be provided on construction. The methods
- /// [`ConditionVariable::wait_while()`] and
+ /// [`ConditionVariable::blocking_wait_while()`] and
/// [`ConditionVariable::timed_wait_while()`] will wait on that preset condition until
/// it is satisfied.
/// The restriction to a preset fixed condition comes with the feature to signal single waiters
@@ -489,7 +489,7 @@ pub trait BasicConditionVariableInterface:
}
/// Condition variable which allows to use multiple conditions in
-/// [`MultiConditionVariable::wait_while()`] and
+/// [`MultiConditionVariable::blocking_wait_while()`] and
/// [`MultiConditionVariable::timed_wait_while()`] concurrently but with the draw
/// back that only all waiters can be triggered and not one.
/// The reason is when one waits on multiple
@@ -505,7 +505,7 @@ pub trait BasicConditionVariableInterface:
/// is written.
/// The condition variable provides the following features:
/// * wait on the condition variable: [wait](BasicConditionVariableInterface::wait()), [timed_wait](BasicConditionVariableInterface::timed_wait())
-/// * wait until a defined condition occurs: [wait_while](MultiConditionVariable::wait_while()), [timed_wait_while](MultiConditionVariable::timed_wait_while())
+/// * wait until a defined condition occurs: [blocking_wait_while](MultiConditionVariable::blocking_wait_while()), [timed_wait_while](MultiConditionVariable::timed_wait_while())
/// * modify condition variable and then notify waiters:
/// [notify_all](MultiConditionVariable::notify_all()), [modify_notify_all](MultiConditionVariable::modify_notify_all())
/// * trigger waiters without changing condition variable: [trigger_all](BasicConditionVariableInterface::trigger_all())
@@ -530,7 +530,7 @@ pub trait BasicConditionVariableInterface:
/// thread::scope(|s| {
/// let t1 = s.spawn(|| {
/// // wait until value is 5000
-/// let guard = cv.wait_while(|t| *t == 5000).expect("failed to wait");
+/// let guard = cv.blocking_wait_while(|t| *t == 5000).expect("failed to wait");
/// println!("cv value changed to 5000");
/// });
///
@@ -589,12 +589,11 @@ impl<'mtx_handle, T: Debug> MultiConditionVariable<'mtx_handle, T> {
/// [`MultiConditionVariable::modify_notify_all()`] or
/// [`BasicConditionVariableInterface::trigger_all()`]
/// and the provided predicate returns true.
- pub fn wait_while bool>(
+ pub fn blocking_wait_while bool>(
&self,
mut predicate: P,
) -> Result, ConditionVariableWaitError<'_, '_, T>> {
- let mut guard =
- fail!(from self, when self.mutex.lock(), "Failed to lock mutex in wait_while.");
+ let mut guard = fail!(from self, when self.mutex.lock(), "Failed to lock mutex in blocking_wait_while.");
while !(predicate)(&mut *guard) {
self.condvar.pthread_wait(&self.mutex)?;
@@ -742,7 +741,7 @@ impl Drop for ConditionVariableGuard<'_, '_, '_, T> {
}
/// Condition variable which requires a fixed predicate on creation which is then used in
-/// [`ConditionVariable::wait_while()`] and
+/// [`ConditionVariable::blocking_wait_while()`] and
/// [`ConditionVariable::timed_wait_while()`] concurrently with the benefit of triggering
/// single waiters.
/// The reason is when one waits on multiple
@@ -758,7 +757,7 @@ impl Drop for ConditionVariableGuard<'_, '_, '_, T> {
/// is written.
/// The condition variable provides the following features:
/// * wait on the condition variable: [wait](BasicConditionVariableInterface::wait()), [timed_wait](BasicConditionVariableInterface::timed_wait())
-/// * wait until a defined condition occurs: [wait_while](ConditionVariable::wait_while()), [timed_wait_while](ConditionVariable::timed_wait_while())
+/// * wait until a defined condition occurs: [blocking_wait_while](ConditionVariable::blocking_wait_while()), [timed_wait_while](ConditionVariable::timed_wait_while())
/// * modify condition variable and then notify waiters:
/// [notify_all](ConditionVariable::notify_all()), [modify_notify_all](ConditionVariable::modify_notify_all()),
/// [notify_one](ConditionVariable::notify_one()), [modify_notify_one](ConditionVariable::modify_notify_one())
@@ -786,7 +785,7 @@ impl Drop for ConditionVariableGuard<'_, '_, '_, T> {
/// thread::scope(|s| {
/// let t1 = s.spawn(|| {
/// // wait until value is 5000
-/// let guard = cv.wait_while().expect("failed to wait");
+/// let guard = cv.blocking_wait_while().expect("failed to wait");
/// println!("cv value is greater or equal 5000");
/// });
///
@@ -856,13 +855,14 @@ impl<'mtx_handle, T: Debug> ConditionVariable<'mtx_handle, T> {
/// [`BasicConditionVariableInterface::trigger_all()`] or
/// [`ConditionVariable::trigger_one()`]
/// and the provided predicate returns true.
- pub fn wait_while(
+ pub fn blocking_wait_while(
&self,
) -> Result<
MutexGuard<'_, '_, ConditionVariableData>,
ConditionVariableWaitError<'_, '_, ConditionVariableData>,
> {
- let guard = fail!(from self, when self.mutex.lock(), "failed to lock mutex in wait_while");
+ let guard =
+ fail!(from self, when self.mutex.lock(), "failed to lock mutex in blocking_wait_while");
while !self.call_underlying_predicate(&guard) {
self.condvar.pthread_wait(&self.mutex)?;
diff --git a/iceoryx2-bb/posix/src/config.rs b/iceoryx2-bb/posix/src/config.rs
index fd929b49d..2bcdd432f 100644
--- a/iceoryx2-bb/posix/src/config.rs
+++ b/iceoryx2-bb/posix/src/config.rs
@@ -38,12 +38,17 @@ pub const ADAPTIVE_WAIT_INITIAL_WAITING_TIME: Duration = Duration::from_micros(1
pub const ADAPTIVE_WAIT_FINAL_WAITING_TIME: Duration = Duration::from_millis(10);
// directories
-pub const TEMP_DIRECTORY: Path =
- unsafe { Path::new_unchecked(iceoryx2_pal_configuration::TEMP_DIRECTORY) };
-pub const TEST_DIRECTORY: Path =
- unsafe { Path::new_unchecked(iceoryx2_pal_configuration::TEST_DIRECTORY) };
-pub const SHARED_MEMORY_DIRECTORY: Path =
- unsafe { Path::new_unchecked(iceoryx2_pal_configuration::SHARED_MEMORY_DIRECTORY) };
+pub fn temp_directory() -> Path {
+ unsafe { Path::new_unchecked(iceoryx2_pal_configuration::TEMP_DIRECTORY) }
+}
+
+pub fn test_directory() -> Path {
+ unsafe { Path::new_unchecked(iceoryx2_pal_configuration::TEST_DIRECTORY) }
+}
+
+pub fn shared_memory_directory() -> Path {
+ unsafe { Path::new_unchecked(iceoryx2_pal_configuration::SHARED_MEMORY_DIRECTORY) }
+}
// TODO unable to verify?
pub const ACL_LIST_CAPACITY: u32 = 25;
diff --git a/iceoryx2-bb/posix/src/mutex.rs b/iceoryx2-bb/posix/src/mutex.rs
index a1f2725cf..13315c0f5 100644
--- a/iceoryx2-bb/posix/src/mutex.rs
+++ b/iceoryx2-bb/posix/src/mutex.rs
@@ -266,7 +266,12 @@ pub enum MutexThreadTerminationBehavior {
/// mutex owning
/// thread/process dies the mutex is put into an inconsistent state which can be recovered with
/// [`Mutex::make_consistent()`]. The inconsistent state is detected by the next instance which
- /// calls [`Mutex::lock()`], [`Mutex::try_lock()`] or [`Mutex::timed_lock()`].
+ /// calls [`Mutex::try_lock()`] or [`Mutex::timed_lock()`].
+ ///
+ /// **Important:** If the owner dies after another thread has already locked the [`Mutex`] it
+ /// may become impossible to recover the [`Mutex`]. Therefore, this feature should be used
+ /// only in combination with either [`Mutex::try_lock`] or [`Mutex::timed_lock()`] and
+ /// never with [`Mutex::lock()`].
///
/// This is also known as robust mutex.
ReleaseWhenLocked = posix::PTHREAD_MUTEX_ROBUST,
diff --git a/iceoryx2-bb/posix/src/thread.rs b/iceoryx2-bb/posix/src/thread.rs
index 3d42d645c..309dd96d2 100644
--- a/iceoryx2-bb/posix/src/thread.rs
+++ b/iceoryx2-bb/posix/src/thread.rs
@@ -48,7 +48,7 @@
//!
//! ## Create a highly customized thread with guarded stack
//!
-//! ```
+//! ```ignore
//! use iceoryx2_bb_posix::thread::*;
//! use iceoryx2_bb_posix::scheduler::*;
//! use iceoryx2_bb_posix::system_configuration::*;
diff --git a/iceoryx2-bb/posix/tests/condition_variable_tests.rs b/iceoryx2-bb/posix/tests/condition_variable_tests.rs
index b48099683..fd9d78647 100644
--- a/iceoryx2-bb/posix/tests/condition_variable_tests.rs
+++ b/iceoryx2-bb/posix/tests/condition_variable_tests.rs
@@ -12,13 +12,14 @@
use iceoryx2_bb_posix::condition_variable::*;
use iceoryx2_bb_testing::assert_that;
+use iceoryx2_bb_testing::watchdog::Watchdog;
use std::sync::atomic::{AtomicI32, Ordering};
use std::sync::Arc;
use std::thread;
use std::time::Duration;
use std::time::Instant;
-static TIMEOUT: Duration = Duration::from_millis(10);
+static TIMEOUT: Duration = Duration::from_millis(100);
#[test]
fn multi_condition_variable_construction_works() {
@@ -48,7 +49,7 @@ fn multi_condition_variable_wait_while_is_signalled_by_notify_all() {
thread::scope(|s| {
let t1 = s.spawn(|| {
- let guard = sut.wait_while(|t| *t == 4456).unwrap();
+ let guard = sut.blocking_wait_while(|t| *t == 4456).unwrap();
assert_that!(*guard, eq 4456);
});
@@ -77,7 +78,7 @@ fn multi_condition_variable_wait_while_is_signalled_by_modify_notify_all() {
thread::scope(|s| {
let t1 = s.spawn(|| {
- let guard = sut.wait_while(|t| *t == 4456).unwrap();
+ let guard = sut.blocking_wait_while(|t| *t == 4456).unwrap();
assert_that!(*guard, eq 4456);
});
@@ -253,14 +254,14 @@ fn condition_variable_notify_all_signals_all_waiters() {
let sut_thread1 = Arc::clone(&sut);
let counter_thread1 = Arc::clone(&counter);
let t1 = s.spawn(move || {
- sut_thread1.wait_while().unwrap();
+ sut_thread1.blocking_wait_while().unwrap();
counter_thread1.fetch_add(1, Ordering::Relaxed);
});
let sut_thread2 = Arc::clone(&sut);
let counter_thread2 = Arc::clone(&counter);
let t2 = s.spawn(move || {
- sut_thread2.wait_while().unwrap();
+ sut_thread2.blocking_wait_while().unwrap();
counter_thread2.fetch_add(1, Ordering::Relaxed);
});
@@ -299,14 +300,14 @@ fn condition_variable_notify_one_signals_one_waiter() {
let sut_thread1 = Arc::clone(&sut);
let counter_thread1 = Arc::clone(&counter);
let t1 = s.spawn(move || {
- sut_thread1.wait_while().unwrap();
+ sut_thread1.blocking_wait_while().unwrap();
counter_thread1.fetch_add(1, Ordering::Relaxed);
});
let sut_thread2 = Arc::clone(&sut);
let counter_thread2 = Arc::clone(&counter);
let t2 = s.spawn(move || {
- sut_thread2.wait_while().unwrap();
+ sut_thread2.blocking_wait_while().unwrap();
counter_thread2.fetch_add(1, Ordering::Relaxed);
});
@@ -369,6 +370,7 @@ fn condition_variable_modify_notify_all_signals_all_waiters() {
#[test]
fn condition_variable_modify_notify_one_signals_one_waiter() {
+ let _watchdog = Watchdog::new(Duration::from_secs(10));
let handle = MutexHandle::>::new();
thread::scope(|s| {
let counter = Arc::new(AtomicI32::new(0));
@@ -381,14 +383,14 @@ fn condition_variable_modify_notify_one_signals_one_waiter() {
let sut_thread1 = Arc::clone(&sut);
let counter_thread1 = Arc::clone(&counter);
let t1 = s.spawn(move || {
- sut_thread1.timed_wait_while(TIMEOUT * 10).unwrap();
+ sut_thread1.blocking_wait_while().unwrap();
counter_thread1.fetch_add(1, Ordering::Relaxed);
});
let sut_thread2 = Arc::clone(&sut);
let counter_thread2 = Arc::clone(&counter);
let t2 = s.spawn(move || {
- sut_thread2.timed_wait_while(TIMEOUT * 10).unwrap();
+ sut_thread2.blocking_wait_while().unwrap();
counter_thread2.fetch_add(1, Ordering::Relaxed);
});
@@ -396,6 +398,8 @@ fn condition_variable_modify_notify_one_signals_one_waiter() {
let counter_old_1 = counter.load(Ordering::Relaxed);
sut.modify_notify_one(|value| *value = 2213).unwrap();
+ while counter.load(Ordering::Relaxed) == 0 {}
+
thread::sleep(TIMEOUT);
let counter_old_2 = counter.load(Ordering::Relaxed);
sut.modify_notify_one(|value| *value = 2213).unwrap();
@@ -462,5 +466,5 @@ fn condition_variable_wait_while_does_not_wait_when_predicate_is_fulfilled() {
);
sut.lock().unwrap().value = 9999999;
- assert_that!(sut.wait_while(), is_ok);
+ assert_that!(sut.blocking_wait_while(), is_ok);
}
diff --git a/iceoryx2-bb/posix/tests/directory_tests.rs b/iceoryx2-bb/posix/tests/directory_tests.rs
index 47fc957ac..1b59b8ce3 100644
--- a/iceoryx2-bb/posix/tests/directory_tests.rs
+++ b/iceoryx2-bb/posix/tests/directory_tests.rs
@@ -87,7 +87,7 @@ impl TestFixture {
}
fn generate_directory_name(&mut self) -> Path {
- let mut directory = TEST_DIRECTORY;
+ let mut directory = test_directory();
directory.push(PATH_SEPARATOR).unwrap();
directory.push_bytes(b"dir_tests_").unwrap();
directory
@@ -107,7 +107,7 @@ impl TestFixture {
#[test]
fn directory_temp_directory_does_exist() {
- assert_that!(Directory::does_exist(&TEST_DIRECTORY).unwrap(), eq true);
+ assert_that!(Directory::does_exist(&test_directory()).unwrap(), eq true);
}
#[test]
diff --git a/iceoryx2-bb/posix/tests/file_descriptor_set_tests.rs b/iceoryx2-bb/posix/tests/file_descriptor_set_tests.rs
index 7b09fcaec..3b2bd42e8 100644
--- a/iceoryx2-bb/posix/tests/file_descriptor_set_tests.rs
+++ b/iceoryx2-bb/posix/tests/file_descriptor_set_tests.rs
@@ -38,7 +38,7 @@ fn generate_socket_name() -> FilePath {
)
.unwrap();
- FilePath::from_path_and_file(&TEST_DIRECTORY, &file).unwrap()
+ FilePath::from_path_and_file(&test_directory(), &file).unwrap()
}
#[test]
diff --git a/iceoryx2-bb/posix/tests/file_descriptor_tests.rs b/iceoryx2-bb/posix/tests/file_descriptor_tests.rs
index d326a6201..a9f2bd4c1 100644
--- a/iceoryx2-bb/posix/tests/file_descriptor_tests.rs
+++ b/iceoryx2-bb/posix/tests/file_descriptor_tests.rs
@@ -53,7 +53,7 @@ trait GenericTestBuilder {
impl GenericTestBuilder for File {
fn sut() -> Self {
- let name = FilePath::from_path_and_file(&TEST_DIRECTORY, &generate_name()).unwrap();
+ let name = FilePath::from_path_and_file(&test_directory(), &generate_name()).unwrap();
let file_content = [170u8; 2048];
diff --git a/iceoryx2-bb/posix/tests/file_lock_tests.rs b/iceoryx2-bb/posix/tests/file_lock_tests.rs
index cac8bbe28..ebf28cbc0 100644
--- a/iceoryx2-bb/posix/tests/file_lock_tests.rs
+++ b/iceoryx2-bb/posix/tests/file_lock_tests.rs
@@ -11,7 +11,7 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT
use iceoryx2_bb_container::semantic_string::SemanticString;
-use iceoryx2_bb_posix::config::*;
+use iceoryx2_bb_posix::config;
use iceoryx2_bb_posix::file::*;
use iceoryx2_bb_posix::file_lock::*;
use iceoryx2_bb_posix::process::*;
@@ -38,7 +38,7 @@ fn generate_file_name() -> FilePath {
)
.unwrap();
- FilePath::from_path_and_file(&TEST_DIRECTORY, &file).unwrap()
+ FilePath::from_path_and_file(&config::test_directory(), &file).unwrap()
}
const TIMEOUT: Duration = Duration::from_millis(10);
diff --git a/iceoryx2-bb/posix/tests/file_tests.rs b/iceoryx2-bb/posix/tests/file_tests.rs
index f3e095a3f..1f5b48f54 100644
--- a/iceoryx2-bb/posix/tests/file_tests.rs
+++ b/iceoryx2-bb/posix/tests/file_tests.rs
@@ -33,7 +33,7 @@ fn generate_file_name() -> FilePath {
)
.unwrap();
- FilePath::from_path_and_file(&TEST_DIRECTORY, &file).unwrap()
+ FilePath::from_path_and_file(&test_directory(), &file).unwrap()
}
struct TestFixture {
diff --git a/iceoryx2-bb/posix/tests/metadata_tests.rs b/iceoryx2-bb/posix/tests/metadata_tests.rs
index d9d92f66e..c34c55643 100644
--- a/iceoryx2-bb/posix/tests/metadata_tests.rs
+++ b/iceoryx2-bb/posix/tests/metadata_tests.rs
@@ -28,7 +28,7 @@ use iceoryx2_pal_posix::posix::POSIX_SUPPORT_USERS_AND_GROUPS;
#[test]
fn metadata_reads_basic_stats_correctly() {
let file_name =
- FilePath::from_path_and_file(&TEST_DIRECTORY, &FileName::new(b"meta_test").unwrap())
+ FilePath::from_path_and_file(&test_directory(), &FileName::new(b"meta_test").unwrap())
.unwrap();
let mut file = FileBuilder::new(&file_name)
@@ -50,7 +50,7 @@ fn metadata_reads_owner_and_permission_stats_correctly() {
test_requires!(POSIX_SUPPORT_USERS_AND_GROUPS && POSIX_SUPPORT_PERMISSIONS);
let file_name =
- FilePath::from_path_and_file(&TEST_DIRECTORY, &FileName::new(b"meta_test_123").unwrap())
+ FilePath::from_path_and_file(&test_directory(), &FileName::new(b"meta_test_123").unwrap())
.unwrap();
let mut file = FileBuilder::new(&file_name)
diff --git a/iceoryx2-bb/posix/tests/mutex_tests.rs b/iceoryx2-bb/posix/tests/mutex_tests.rs
index b72a5ae32..cfec622c8 100644
--- a/iceoryx2-bb/posix/tests/mutex_tests.rs
+++ b/iceoryx2-bb/posix/tests/mutex_tests.rs
@@ -16,12 +16,13 @@ use iceoryx2_bb_posix::system_configuration::Feature;
use iceoryx2_bb_posix::unmovable_ipc_handle::AcquireIpcHandleError;
use iceoryx2_bb_testing::assert_that;
use iceoryx2_bb_testing::test_requires;
+use iceoryx2_bb_testing::watchdog::Watchdog;
use std::sync::Arc;
use std::sync::Barrier;
use std::thread;
use std::time::Duration;
-const TIMEOUT: Duration = Duration::from_millis(50);
+const TIMEOUT: Duration = Duration::from_millis(100);
#[test]
fn mutex_lock_works() {
@@ -389,6 +390,7 @@ fn mutex_with_deadlock_detection_blocks() {
#[test]
fn mutex_can_be_recovered_when_thread_died() {
+ let _watchdog = Watchdog::new(Duration::from_secs(10));
let handle = MutexHandle::::new();
let sut = MutexBuilder::new()
.thread_termination_behavior(MutexThreadTerminationBehavior::ReleaseWhenLocked)
@@ -403,14 +405,16 @@ fn mutex_can_be_recovered_when_thread_died() {
});
});
- let guard = sut.lock();
- assert_that!(guard, is_err);
- match guard.as_ref().err().as_ref().unwrap() {
- MutexLockError::LockAcquiredButOwnerDied(_) => (),
- _ => assert_that!(true, eq false),
+ loop {
+ let guard = sut.try_lock();
+
+ if guard.is_ok() {
+ assert_that!(guard.as_ref().unwrap(), is_none);
+ } else if let Err(MutexLockError::LockAcquiredButOwnerDied(_)) = guard {
+ sut.make_consistent();
+ break;
+ }
}
- sut.make_consistent();
- drop(guard);
let guard = sut.try_lock();
assert_that!(guard, is_ok);
@@ -429,6 +433,7 @@ fn mutex_can_be_recovered_when_thread_died() {
#[test]
fn mutex_in_unrecoverable_state_if_state_of_leaked_mutex_is_not_repaired() {
+ let _watchdog = Watchdog::new(Duration::from_secs(10));
let handle = MutexHandle::::new();
let sut = MutexBuilder::new()
.thread_termination_behavior(MutexThreadTerminationBehavior::ReleaseWhenLocked)
diff --git a/iceoryx2-bb/posix/tests/shared_memory_tests.rs b/iceoryx2-bb/posix/tests/shared_memory_tests.rs
index 96a6bca98..b4327290f 100644
--- a/iceoryx2-bb/posix/tests/shared_memory_tests.rs
+++ b/iceoryx2-bb/posix/tests/shared_memory_tests.rs
@@ -18,7 +18,7 @@ use iceoryx2_bb_testing::{assert_that, test_requires};
use iceoryx2_pal_posix::posix::POSIX_SUPPORT_PERSISTENT_SHARED_MEMORY;
fn generate_shm_name() -> FileName {
- let mut file_name = FileName::new(b"shm_tests_").unwrap();
+ let mut file_name = FileName::new(b"shared_memory_tests_").unwrap();
file_name
.push_bytes(UniqueSystemId::new().unwrap().value().to_b64().as_bytes())
.unwrap();
@@ -92,7 +92,7 @@ fn shared_memory_create_and_modify_open_works() {
#[test]
fn shared_memory_opening_with_non_fitting_size_fails() {
let shm_name = generate_shm_name();
- let _sut_create = SharedMemoryBuilder::new(&shm_name)
+ let sut_create = SharedMemoryBuilder::new(&shm_name)
.creation_mode(CreationMode::PurgeAndCreate)
.size(1024)
.permission(Permission::OWNER_ALL)
@@ -102,14 +102,14 @@ fn shared_memory_opening_with_non_fitting_size_fails() {
let sut_open1 = SharedMemoryBuilder::new(&shm_name)
.creation_mode(CreationMode::OpenOrCreate)
- .size(8192)
+ .size(sut_create.size() + 1)
.permission(Permission::OWNER_ALL)
.zero_memory(true)
.create();
let sut_open2 = SharedMemoryBuilder::new(&shm_name)
.creation_mode(CreationMode::OpenOrCreate)
- .size(16384)
+ .size(sut_create.size() * 2)
.permission(Permission::OWNER_ALL)
.zero_memory(true)
.create();
diff --git a/iceoryx2-bb/posix/tests/socket_ancillary_tests.rs b/iceoryx2-bb/posix/tests/socket_ancillary_tests.rs
index b0eff3f4a..a82f2969f 100644
--- a/iceoryx2-bb/posix/tests/socket_ancillary_tests.rs
+++ b/iceoryx2-bb/posix/tests/socket_ancillary_tests.rs
@@ -12,7 +12,7 @@
use iceoryx2_bb_container::semantic_string::SemanticString;
use iceoryx2_bb_elementary::unique_id::*;
-use iceoryx2_bb_posix::config::*;
+use iceoryx2_bb_posix::config;
use iceoryx2_bb_posix::file::*;
use iceoryx2_bb_posix::file_descriptor::*;
use iceoryx2_bb_posix::process::ProcessId;
@@ -29,7 +29,7 @@ fn generate_file_name() -> FilePath {
file.push_bytes(UniqueId::new().value().to_string().as_bytes())
.unwrap();
- FilePath::from_path_and_file(&TEST_DIRECTORY, &file).unwrap()
+ FilePath::from_path_and_file(&config::test_directory(), &file).unwrap()
}
struct TestFixture {
diff --git a/iceoryx2-bb/posix/tests/udp_socket_tests.rs b/iceoryx2-bb/posix/tests/udp_socket_tests.rs
index 3e1fc9b94..2aacccfdc 100644
--- a/iceoryx2-bb/posix/tests/udp_socket_tests.rs
+++ b/iceoryx2-bb/posix/tests/udp_socket_tests.rs
@@ -107,12 +107,12 @@ fn udp_socket_when_socket_goes_out_of_scope_address_is_free_again() {
fn udp_socket_server_has_correct_address() {
let sut_server = UdpServerBuilder::new()
.address(ipv4_address::LOCALHOST)
- .port(Port::new(65111))
+ .port(Port::new(55223))
.listen()
.unwrap();
assert_that!(sut_server.address(), eq ipv4_address::LOCALHOST);
- assert_that!(sut_server.port(), eq Port::new(65111));
+ assert_that!(sut_server.port(), eq Port::new(55223));
}
#[test]
diff --git a/iceoryx2-bb/posix/tests/unix_datagram_socket_tests.rs b/iceoryx2-bb/posix/tests/unix_datagram_socket_tests.rs
index e26abeeda..d4cb05ece 100644
--- a/iceoryx2-bb/posix/tests/unix_datagram_socket_tests.rs
+++ b/iceoryx2-bb/posix/tests/unix_datagram_socket_tests.rs
@@ -43,7 +43,7 @@ fn generate_socket_name() -> FilePath {
)
.unwrap();
- FilePath::from_path_and_file(&TEST_DIRECTORY, &file).unwrap()
+ FilePath::from_path_and_file(&test_directory(), &file).unwrap()
}
fn generate_file_name() -> FilePath {
@@ -57,7 +57,7 @@ fn generate_file_name() -> FilePath {
)
.unwrap();
- FilePath::from_path_and_file(&TEST_DIRECTORY, &file).unwrap()
+ FilePath::from_path_and_file(&test_directory(), &file).unwrap()
}
struct TestFixture {
diff --git a/iceoryx2-bb/threadsafe/tests/trigger_queue_tests.rs b/iceoryx2-bb/threadsafe/tests/trigger_queue_tests.rs
index 7513b3488..6ef9f9aa1 100644
--- a/iceoryx2-bb/threadsafe/tests/trigger_queue_tests.rs
+++ b/iceoryx2-bb/threadsafe/tests/trigger_queue_tests.rs
@@ -17,9 +17,10 @@ use std::time::Duration;
use iceoryx2_bb_posix::clock::{nanosleep, Time};
use iceoryx2_bb_posix::mutex::MutexHandle;
use iceoryx2_bb_testing::assert_that;
+use iceoryx2_bb_testing::watchdog::Watchdog;
use iceoryx2_bb_threadsafe::trigger_queue::*;
-const TIMEOUT: Duration = Duration::from_millis(25);
+const TIMEOUT: Duration = Duration::from_millis(100);
const SUT_CAPACITY: usize = 128;
type Sut<'a> = TriggerQueue<'a, usize, SUT_CAPACITY>;
@@ -153,6 +154,7 @@ fn trigger_queue_blocking_push_blocks_until_there_is_space_again() {
let mtx_handle = MutexHandle::new();
let free_handle = UnnamedSemaphoreHandle::new();
let used_handle = UnnamedSemaphoreHandle::new();
+ let _watchdog = Watchdog::new(Duration::from_secs(10));
let sut = Sut::new(&mtx_handle, &free_handle, &used_handle);
@@ -170,10 +172,11 @@ fn trigger_queue_blocking_push_blocks_until_there_is_space_again() {
nanosleep(TIMEOUT).unwrap();
let counter_old = counter.load(Ordering::Relaxed);
sut.blocking_pop();
- nanosleep(TIMEOUT).unwrap();
assert_that!(counter_old, eq 0);
- assert_that!(counter.load(Ordering::Relaxed), eq 1);
+
+ // if the thread is not unblocked the counter stays zero until the watchdog intervenes
+ while counter.load(Ordering::Relaxed) == 0 {}
});
}
@@ -182,6 +185,7 @@ fn trigger_queue_blocking_pop_blocks_until_there_is_something_pushed() {
let mtx_handle = MutexHandle::new();
let free_handle = UnnamedSemaphoreHandle::new();
let used_handle = UnnamedSemaphoreHandle::new();
+ let _watchdog = Watchdog::new(Duration::from_secs(10));
let sut = Sut::new(&mtx_handle, &free_handle, &used_handle);
@@ -196,10 +200,11 @@ fn trigger_queue_blocking_pop_blocks_until_there_is_something_pushed() {
nanosleep(TIMEOUT).unwrap();
let counter_old = counter.load(Ordering::Relaxed);
sut.blocking_push(0);
- nanosleep(TIMEOUT).unwrap();
assert_that!(counter_old, eq 0);
- assert_that!(counter.load(Ordering::Relaxed), eq 1);
+
+ // if the thread is not unblocked the counter stays zero until the watchdog intervenes
+ while counter.load(Ordering::Relaxed) == 0 {}
});
}
diff --git a/iceoryx2-cal/src/communication_channel/message_queue.rs b/iceoryx2-cal/src/communication_channel/message_queue.rs
index 5b5c730de..f9abd4293 100644
--- a/iceoryx2-cal/src/communication_channel/message_queue.rs
+++ b/iceoryx2-cal/src/communication_channel/message_queue.rs
@@ -147,9 +147,9 @@ pub struct Configuration {
impl Default for Configuration {
fn default() -> Self {
Self {
- suffix: DEFAULT_SUFFIX,
- prefix: DEFAULT_PREFIX,
- path_hint: DEFAULT_PATH_HINT,
+ suffix: Channel::<()>::default_suffix(),
+ prefix: Channel::<()>::default_prefix(),
+ path_hint: Channel::<()>::default_path_hint(),
}
}
}
@@ -190,7 +190,7 @@ struct SharedConfiguration {
}
#[derive(Debug)]
-pub struct Creator {
+pub struct Creator {
channel_name: FileName,
enable_safe_overflow: bool,
buffer_size: usize,
@@ -291,7 +291,7 @@ impl CommunicationChannelCreator> for Creator
}
#[derive(Debug)]
-pub struct Connector {
+pub struct Connector {
channel_name: FileName,
config: Configuration,
_phantom_data: PhantomData,
diff --git a/iceoryx2-cal/src/communication_channel/mod.rs b/iceoryx2-cal/src/communication_channel/mod.rs
index 31add38da..7517a98dc 100644
--- a/iceoryx2-cal/src/communication_channel/mod.rs
+++ b/iceoryx2-cal/src/communication_channel/mod.rs
@@ -72,7 +72,6 @@ pub mod unix_datagram;
use std::fmt::Debug;
-use iceoryx2_bb_posix::config::TEMP_DIRECTORY;
use iceoryx2_bb_system_types::file_name::FileName;
use iceoryx2_bb_system_types::path::Path;
@@ -81,15 +80,6 @@ use crate::named_concept::{NamedConcept, NamedConceptBuilder, NamedConceptMgmt};
/// The buffer size which the receiver has at least by default
pub const DEFAULT_RECEIVER_BUFFER_SIZE: usize = 8;
-/// The default suffix of every communication channel
-pub const DEFAULT_SUFFIX: FileName = unsafe { FileName::new_unchecked(b".com") };
-
-/// The default prefix of every communication channel
-pub const DEFAULT_PREFIX: FileName = unsafe { FileName::new_unchecked(b"iox2_") };
-
-/// The default path hint for every communication channel
-pub const DEFAULT_PATH_HINT: Path = TEMP_DIRECTORY;
-
/// Describes failures when sending data
#[derive(Debug, Clone, Copy, Eq, Hash, PartialEq)]
pub enum CommunicationChannelSendError {
@@ -207,4 +197,9 @@ pub trait CommunicationChannel: Sized + Debug + NamedConceptMgmt {
fn has_configurable_buffer_size() -> bool {
false
}
+
+ /// The default suffix of every communication channel
+ fn default_suffix() -> FileName {
+ unsafe { FileName::new_unchecked(b".com") }
+ }
}
diff --git a/iceoryx2-cal/src/communication_channel/posix_shared_memory.rs b/iceoryx2-cal/src/communication_channel/posix_shared_memory.rs
index 4ba42505a..d4e27984a 100644
--- a/iceoryx2-cal/src/communication_channel/posix_shared_memory.rs
+++ b/iceoryx2-cal/src/communication_channel/posix_shared_memory.rs
@@ -79,9 +79,9 @@ pub struct Configuration {
impl Default for Configuration {
fn default() -> Self {
Self {
- suffix: DEFAULT_SUFFIX,
- path_hint: DEFAULT_PATH_HINT,
- prefix: DEFAULT_PREFIX,
+ suffix: Channel::default_suffix(),
+ path_hint: Channel::default_path_hint(),
+ prefix: Channel::default_prefix(),
}
}
}
diff --git a/iceoryx2-cal/src/communication_channel/process_local.rs b/iceoryx2-cal/src/communication_channel/process_local.rs
index 6ad4f2918..5719c128e 100644
--- a/iceoryx2-cal/src/communication_channel/process_local.rs
+++ b/iceoryx2-cal/src/communication_channel/process_local.rs
@@ -69,9 +69,9 @@ pub struct Configuration {
impl Default for Configuration {
fn default() -> Self {
Self {
- suffix: DEFAULT_SUFFIX,
- prefix: DEFAULT_PREFIX,
- path_hint: DEFAULT_PATH_HINT,
+ suffix: Channel::default_suffix(),
+ prefix: Channel::default_prefix(),
+ path_hint: Channel::default_path_hint(),
}
}
}
diff --git a/iceoryx2-cal/src/communication_channel/unix_datagram.rs b/iceoryx2-cal/src/communication_channel/unix_datagram.rs
index ae391e85a..e62cdeb10 100644
--- a/iceoryx2-cal/src/communication_channel/unix_datagram.rs
+++ b/iceoryx2-cal/src/communication_channel/unix_datagram.rs
@@ -37,9 +37,9 @@ pub struct Configuration {
impl Default for Configuration {
fn default() -> Self {
Self {
- suffix: DEFAULT_SUFFIX,
- prefix: DEFAULT_PREFIX,
- path_hint: DEFAULT_PATH_HINT,
+ suffix: Channel::<()>::default_suffix(),
+ prefix: Channel::<()>::default_prefix(),
+ path_hint: Channel::<()>::default_path_hint(),
}
}
}
@@ -165,7 +165,7 @@ impl CommunicationChannel for Channel {
}
#[derive(Debug)]
-pub struct Creator {
+pub struct Creator {
channel_name: FileName,
enable_safe_overflow: bool,
buffer_size: usize,
@@ -240,7 +240,7 @@ impl CommunicationChannelCreator> for Creator
}
#[derive(Debug)]
-pub struct Connector {
+pub struct Connector {
channel_name: FileName,
config: Configuration,
_phantom_data: PhantomData,
diff --git a/iceoryx2-cal/src/dynamic_storage/mod.rs b/iceoryx2-cal/src/dynamic_storage/mod.rs
index 1fc28fd4c..3f26ab7da 100644
--- a/iceoryx2-cal/src/dynamic_storage/mod.rs
+++ b/iceoryx2-cal/src/dynamic_storage/mod.rs
@@ -57,24 +57,13 @@
use std::fmt::Debug;
use iceoryx2_bb_memory::bump_allocator::BumpAllocator;
-use iceoryx2_bb_posix::config::TEMP_DIRECTORY;
use iceoryx2_bb_system_types::file_name::FileName;
-use iceoryx2_bb_system_types::path::Path;
use crate::static_storage::file::{NamedConcept, NamedConceptBuilder, NamedConceptMgmt};
pub mod posix_shared_memory;
pub mod process_local;
-/// The default suffix of every dynamic storage
-pub const DEFAULT_SUFFIX: FileName = unsafe { FileName::new_unchecked(b".dyn") };
-
-/// The default prefix of every dynamic storage
-pub const DEFAULT_PREFIX: FileName = unsafe { FileName::new_unchecked(b"iox2_") };
-
-/// The default path hint for every dynamic storage
-pub const DEFAULT_PATH_HINT: Path = TEMP_DIRECTORY;
-
/// Describes failures when creating a new [`DynamicStorage`]
#[derive(Debug, Clone, Copy, Eq, Hash, PartialEq)]
pub enum DynamicStorageCreateError {
@@ -155,4 +144,9 @@ pub trait DynamicStorage: Sized + Debug + NamedConceptMgmt + Nam
/// can be accessed by multiple processes concurrently therefore it must be constant or
/// thread-safe.
fn get(&self) -> &T;
+
+ /// The default suffix of every dynamic storage
+ fn default_suffix() -> FileName {
+ unsafe { FileName::new_unchecked(b".dyn") }
+ }
}
diff --git a/iceoryx2-cal/src/dynamic_storage/posix_shared_memory.rs b/iceoryx2-cal/src/dynamic_storage/posix_shared_memory.rs
index 05a07518b..0a28ec328 100644
--- a/iceoryx2-cal/src/dynamic_storage/posix_shared_memory.rs
+++ b/iceoryx2-cal/src/dynamic_storage/posix_shared_memory.rs
@@ -59,7 +59,7 @@ const IS_INITIALIZED_STATE_VALUE: u64 = 0xbeefaffedeadbeef;
/// The builder of [`Storage`].
#[derive(Debug)]
-pub struct Builder {
+pub struct Builder {
storage_name: FileName,
supplementary_size: usize,
has_ownership: bool,
@@ -67,7 +67,7 @@ pub struct Builder {
_phantom_data: PhantomData,
}
-#[derive(Clone, Debug)]
+#[derive(Debug, Clone)]
pub struct Configuration {
suffix: FileName,
prefix: FileName,
@@ -83,9 +83,9 @@ struct Data {
impl Default for Configuration {
fn default() -> Self {
Self {
- path: DEFAULT_PATH_HINT,
- suffix: DEFAULT_SUFFIX,
- prefix: DEFAULT_PREFIX,
+ path: Storage::<()>::default_path_hint(),
+ suffix: Storage::<()>::default_suffix(),
+ prefix: Storage::<()>::default_prefix(),
}
}
}
diff --git a/iceoryx2-cal/src/dynamic_storage/process_local.rs b/iceoryx2-cal/src/dynamic_storage/process_local.rs
index cfd665628..857cad362 100644
--- a/iceoryx2-cal/src/dynamic_storage/process_local.rs
+++ b/iceoryx2-cal/src/dynamic_storage/process_local.rs
@@ -67,7 +67,7 @@ struct StorageDetails {
layout: Layout,
}
-#[derive(Debug, PartialEq, Eq, Clone, Copy)]
+#[derive(PartialEq, Eq, Copy, Clone, Debug)]
pub struct Configuration {
suffix: FileName,
prefix: FileName,
@@ -77,9 +77,9 @@ pub struct Configuration {
impl Default for Configuration {
fn default() -> Self {
Self {
- suffix: DEFAULT_SUFFIX,
- prefix: DEFAULT_PREFIX,
- path_hint: DEFAULT_PATH_HINT,
+ suffix: Storage::<()>::default_suffix(),
+ prefix: Storage::<()>::default_prefix(),
+ path_hint: Storage::<()>::default_path_hint(),
}
}
}
@@ -273,7 +273,7 @@ impl Drop for Storage {
}
#[derive(Debug)]
-pub struct Builder {
+pub struct Builder {
name: FileName,
supplementary_size: usize,
has_ownership: bool,
diff --git a/iceoryx2-cal/src/event/mod.rs b/iceoryx2-cal/src/event/mod.rs
index 121f3ee1f..72374a3f8 100644
--- a/iceoryx2-cal/src/event/mod.rs
+++ b/iceoryx2-cal/src/event/mod.rs
@@ -16,7 +16,6 @@ pub mod unix_datagram_socket;
use std::{fmt::Debug, time::Duration};
pub use crate::named_concept::{NamedConcept, NamedConceptBuilder, NamedConceptMgmt};
-use iceoryx2_bb_posix::config::TEMP_DIRECTORY;
pub use iceoryx2_bb_system_types::file_name::FileName;
pub use iceoryx2_bb_system_types::path::Path;
@@ -78,15 +77,6 @@ impl std::fmt::Display for ListenerCreateError {
impl std::error::Error for ListenerCreateError {}
-/// The default suffix of every event
-pub const DEFAULT_SUFFIX: FileName = unsafe { FileName::new_unchecked(b".event") };
-
-/// The default prefix of every event
-pub const DEFAULT_PREFIX: FileName = unsafe { FileName::new_unchecked(b"iox2_") };
-
-/// The default path hint for every event
-pub const DEFAULT_PATH_HINT: Path = TEMP_DIRECTORY;
-
pub trait TriggerId: Debug + Copy {}
impl TriggerId for u64 {}
@@ -117,4 +107,9 @@ pub trait Event: Sized + NamedConceptMgmt + Debug {
type NotifierBuilder: NotifierBuilder;
type Listener: Listener;
type ListenerBuilder: ListenerBuilder;
+
+ /// The default suffix of every event
+ fn default_suffix() -> FileName {
+ unsafe { FileName::new_unchecked(b".event") }
+ }
}
diff --git a/iceoryx2-cal/src/event/process_local.rs b/iceoryx2-cal/src/event/process_local.rs
index 06955425f..2300b29de 100644
--- a/iceoryx2-cal/src/event/process_local.rs
+++ b/iceoryx2-cal/src/event/process_local.rs
@@ -64,23 +64,25 @@ static PROCESS_LOCAL_STORAGE: Lazy>> = Laz
});
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
-pub struct Configuration {
+pub struct Configuration {
suffix: FileName,
prefix: FileName,
path: Path,
+ _phantom: PhantomData,
}
-impl Default for Configuration {
+impl Default for Configuration {
fn default() -> Self {
Self {
- path: DEFAULT_PATH_HINT,
- suffix: DEFAULT_SUFFIX,
- prefix: DEFAULT_PREFIX,
+ path: EventImpl::::default_path_hint(),
+ suffix: EventImpl::::default_suffix(),
+ prefix: EventImpl::::default_prefix(),
+ _phantom: PhantomData,
}
}
}
-impl NamedConceptConfiguration for Configuration {
+impl NamedConceptConfiguration for Configuration {
fn prefix(mut self, value: FileName) -> Self {
self.prefix = value;
self
@@ -114,7 +116,7 @@ pub struct Duplex {
name: FileName,
management: Arc>,
has_ownership: bool,
- config: Configuration,
+ config: Configuration,
}
impl NamedConcept for Duplex {
@@ -150,7 +152,7 @@ impl Notifier for Duplex {
impl Drop for Duplex {
fn drop(&mut self) {
if self.has_ownership {
- fatal_panic!(from self, when unsafe { Event::::remove_cfg(&self.name, &self.config) },
+ fatal_panic!(from self, when unsafe { EventImpl::::remove_cfg(&self.name, &self.config) },
"This should never happen! Unable to remove resources.");
}
}
@@ -193,7 +195,7 @@ impl Listener for Duplex {
fn blocking_wait(&self) -> Result, ListenerWaitError> {
let msg = "Failed to blocking_wait";
- match self.management.as_ref().borrow_cvar().wait_while() {
+ match self.management.as_ref().borrow_cvar().blocking_wait_while() {
Err(v) => {
fail!(from self, with ListenerWaitError::InternalFailure,
"{} due to an internal failure in the underlying condition variable ({:?}).", msg, v);
@@ -206,11 +208,13 @@ impl Listener for Duplex {
#[derive(Debug)]
pub struct Builder {
name: FileName,
- config: Configuration,
+ config: Configuration,
_data: PhantomData,
}
-impl NamedConceptBuilder> for Builder {
+impl NamedConceptBuilder>
+ for Builder
+{
fn new(name: &FileName) -> Self {
Self {
name: *name,
@@ -219,13 +223,15 @@ impl NamedConceptBuilder> for Buil
}
}
- fn config(mut self, config: &Configuration) -> Self {
+ fn config(mut self, config: &Configuration) -> Self {
self.config = *config;
self
}
}
-impl NotifierBuilder> for Builder {
+impl NotifierBuilder>
+ for Builder
+{
fn open(self) -> Result, NotifierCreateError> {
let msg = "Failed to open event";
@@ -255,7 +261,9 @@ impl NotifierBuilder
}
}
-impl ListenerBuilder> for Builder {
+impl ListenerBuilder>
+ for Builder
+{
fn create(self) -> Result, ListenerCreateError> {
let msg = "Failed to create event";
@@ -322,19 +330,19 @@ impl ListenerBuilder
}
#[derive(Debug)]
-pub struct Event {
+pub struct EventImpl {
_data: PhantomData,
}
-impl crate::event::Event for Event {
+impl crate::event::Event for EventImpl {
type Notifier = Duplex;
type Listener = Duplex;
type NotifierBuilder = Builder;
type ListenerBuilder = Builder;
}
-impl NamedConceptMgmt for Event {
- type Configuration = Configuration;
+impl NamedConceptMgmt for EventImpl {
+ type Configuration = Configuration;
fn does_exist_cfg(
name: &FileName,
diff --git a/iceoryx2-cal/src/event/unix_datagram_socket.rs b/iceoryx2-cal/src/event/unix_datagram_socket.rs
index d44a24b4d..699d37ece 100644
--- a/iceoryx2-cal/src/event/unix_datagram_socket.rs
+++ b/iceoryx2-cal/src/event/unix_datagram_socket.rs
@@ -22,23 +22,25 @@ use iceoryx2_bb_posix::{
pub use iceoryx2_bb_system_types::file_name::FileName;
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
-pub struct Configuration {
+pub struct Configuration {
suffix: FileName,
prefix: FileName,
path: Path,
+ _phantom: PhantomData,
}
-impl Default for Configuration {
+impl Default for Configuration {
fn default() -> Self {
Self {
- path: DEFAULT_PATH_HINT,
- suffix: DEFAULT_SUFFIX,
- prefix: DEFAULT_PREFIX,
+ path: EventImpl::::default_path_hint(),
+ suffix: EventImpl::::default_suffix(),
+ prefix: EventImpl::::default_prefix(),
+ _phantom: PhantomData,
}
}
}
-impl NamedConceptConfiguration for Configuration {
+impl NamedConceptConfiguration for Configuration {
fn prefix(mut self, value: FileName) -> Self {
self.prefix = value;
self
@@ -67,19 +69,21 @@ impl NamedConceptConfiguration for Configuration {
}
}
-impl From for crate::communication_channel::unix_datagram::Configuration {
- fn from(value: Configuration) -> Self {
+impl From>
+ for crate::communication_channel::unix_datagram::Configuration
+{
+ fn from(value: Configuration) -> Self {
Self::default().suffix(value.suffix).path_hint(value.path)
}
}
#[derive(Debug)]
-pub struct Event {
+pub struct EventImpl {
_data: PhantomData,
}
-impl NamedConceptMgmt for Event {
- type Configuration = Configuration;
+impl NamedConceptMgmt for EventImpl {
+ type Configuration = Configuration;
fn does_exist_cfg(
name: &FileName,
@@ -105,7 +109,7 @@ impl NamedConceptMgmt for Event {
}
}
-impl crate::event::Event for Event {
+impl crate::event::Event for EventImpl {
type Notifier = Notifier;
type Listener = Listener;
type NotifierBuilder = NotifierBuilder;
@@ -147,11 +151,13 @@ impl crate::event::Notifier for Notifier
#[derive(Debug)]
pub struct NotifierBuilder {
name: FileName,
- config: Configuration,
+ config: Configuration,
_data: PhantomData,
}
-impl NamedConceptBuilder> for NotifierBuilder {
+impl NamedConceptBuilder>
+ for NotifierBuilder
+{
fn new(name: &FileName) -> Self {
Self {
name: *name,
@@ -160,13 +166,13 @@ impl NamedConceptBuilder> for Noti
}
}
- fn config(mut self, config: &Configuration) -> Self {
+ fn config(mut self, config: &Configuration) -> Self {
self.config = *config;
self
}
}
-impl crate::event::NotifierBuilder>
+impl crate::event::NotifierBuilder>
for NotifierBuilder
{
fn open(self) -> Result, NotifierCreateError> {
@@ -275,11 +281,13 @@ impl crate::event::Listener for Listener
#[derive(Debug)]
pub struct ListenerBuilder {
name: FileName,
- config: Configuration,
+ config: Configuration,
_data: PhantomData,
}
-impl NamedConceptBuilder> for ListenerBuilder {
+impl NamedConceptBuilder>
+ for ListenerBuilder
+{
fn new(name: &FileName) -> Self {
Self {
name: *name,
@@ -288,13 +296,13 @@ impl NamedConceptBuilder> for List
}
}
- fn config(mut self, config: &Configuration) -> Self {
+ fn config(mut self, config: &Configuration) -> Self {
self.config = *config;
self
}
}
-impl crate::event::ListenerBuilder>
+impl crate::event::ListenerBuilder>
for ListenerBuilder
{
fn create(self) -> Result, ListenerCreateError> {
diff --git a/iceoryx2-cal/src/named_concept.rs b/iceoryx2-cal/src/named_concept.rs
index 2dfdf4cab..820e752ef 100644
--- a/iceoryx2-cal/src/named_concept.rs
+++ b/iceoryx2-cal/src/named_concept.rs
@@ -178,4 +178,14 @@ pub trait NamedConceptMgmt {
/// Returns a list of all available concepts with a custom configuration.
fn list_cfg(cfg: &Self::Configuration) -> Result, NamedConceptListError>;
+
+ /// The default prefix of every zero copy connection
+ fn default_prefix() -> FileName {
+ unsafe { FileName::new_unchecked(b"iox2_") }
+ }
+
+ /// The default path hint for every zero copy connection
+ fn default_path_hint() -> Path {
+ iceoryx2_bb_posix::config::temp_directory()
+ }
}
diff --git a/iceoryx2-cal/src/shared_memory/mod.rs b/iceoryx2-cal/src/shared_memory/mod.rs
index 96b56c61e..d9e819d53 100644
--- a/iceoryx2-cal/src/shared_memory/mod.rs
+++ b/iceoryx2-cal/src/shared_memory/mod.rs
@@ -60,21 +60,10 @@ pub mod process_local;
use std::fmt::Debug;
use iceoryx2_bb_elementary::allocator::DeallocationError;
-use iceoryx2_bb_posix::config::TEMP_DIRECTORY;
pub use crate::shm_allocator::*;
use crate::static_storage::file::{NamedConcept, NamedConceptBuilder, NamedConceptMgmt};
use iceoryx2_bb_system_types::file_name::FileName;
-use iceoryx2_bb_system_types::path::Path;
-
-/// The default suffix of every shared memory
-pub const DEFAULT_SUFFIX: FileName = unsafe { FileName::new_unchecked(b".shm") };
-
-/// The default prefix of every shared memory
-pub const DEFAULT_PREFIX: FileName = unsafe { FileName::new_unchecked(b"iox2_") };
-
-/// The default path hint for every shared memory
-pub const DEFAULT_PATH_HINT: Path = TEMP_DIRECTORY;
/// Failure returned by [`SharedMemoryBuilder::create()`]
#[derive(Debug, Clone, Copy, Eq, Hash, PartialEq)]
@@ -159,4 +148,9 @@ pub trait SharedMemory:
/// Releases the ownership of the [`SharedMemory`] meaning when it goes out of scope the
/// underlying resource will not be removed.
fn release_ownership(&mut self);
+
+ /// The default suffix of every shared memory
+ fn default_suffix() -> FileName {
+ unsafe { FileName::new_unchecked(b".shm") }
+ }
}
diff --git a/iceoryx2-cal/src/shared_memory/posix.rs b/iceoryx2-cal/src/shared_memory/posix.rs
index 8e0ef2f2a..345b7904f 100644
--- a/iceoryx2-cal/src/shared_memory/posix.rs
+++ b/iceoryx2-cal/src/shared_memory/posix.rs
@@ -32,30 +32,46 @@ use crate::static_storage::file::{
const IS_INITIALIZED_STATE_VALUE: u64 = 0xbeefaffedeadbeef;
-#[derive(Clone, Debug)]
-pub struct Configuration {
+#[derive(Debug)]
+pub struct Configuration {
pub is_memory_locked: bool,
pub permission: Permission,
pub zero_memory: bool,
path: Path,
suffix: FileName,
prefix: FileName,
+ _phantom: PhantomData,
}
-impl Default for Configuration {
+impl Default for Configuration {
fn default() -> Self {
Self {
is_memory_locked: false,
permission: Permission::OWNER_ALL,
zero_memory: true,
- path: DEFAULT_PATH_HINT,
- suffix: DEFAULT_SUFFIX,
- prefix: DEFAULT_PREFIX,
+ path: Memory::