Skip to content

Commit bd6a1de

Browse files
committed
[eclipse-iceoryx#139] Add detailed explanation and reworded doc
1 parent 6f7ab35 commit bd6a1de

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

iceoryx2-cal/src/event/common.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,13 @@ pub mod details {
383383
fn try_wait(
384384
&self,
385385
) -> Result<Option<crate::event::TriggerId>, crate::event::ListenerWaitError> {
386-
// collect all notifications until no more are available
386+
// collect all notifications until no more are available, otherwise it is possible
387+
// that blocking_wait and timed_wait are becoming non-blocking when the same id is
388+
// triggered multiple times in combination with a bitset id_tracker since the bit is
389+
// set only once but the signal is triggered whenever the user sets the bit.
390+
//
391+
// of course one could check if the id_tracker has already set the bit, but this is
392+
// not possible on every implemenation. a bitset can check it a mpmc::queue maybe not.
387393
while unsafe { self.storage.get().signal_mechanism.try_wait()? } {}
388394
Ok(unsafe { self.storage.get().id_tracker.acquire() })
389395
}

iceoryx2-cal/src/event/signal_mechanism/mod.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,22 @@ pub trait SignalMechanism: Send + Sync + Debug {
2727
/// Initializes the [`SignalMechanism`] in place.
2828
///
2929
/// # Safety
30-
/// * [`SignalMechanism::init()`] must not be called before
30+
/// * [`SignalMechanism::init()`] must called exactly once before all other methods
3131
unsafe fn init(&mut self) -> Result<(), ListenerCreateError>;
3232

3333
/// Notifies the counter-part of the [`SignalMechanism`] meaning
3434
/// that a [`SignalMechanism::try_wait()`], [`SignalMechanism::timed_wait()`]
3535
/// or [`SignalMechanism::blocking_wait()`] call wakes up and returns true.
3636
///
3737
/// # Safety
38-
/// * [`SignalMechanism::init()`] must be called before
38+
/// * [`SignalMechanism::init()`] must have been called exactly once
3939
/// * Must not be dropped while in use from another process
4040
unsafe fn notify(&self) -> Result<(), NotifierNotifyError>;
4141

4242
/// When a signal was received it returns true, otherwise false.
4343
///
4444
/// # Safety
45-
/// * [`SignalMechanism::init()`] must be called before
45+
/// * [`SignalMechanism::init()`] must have been called exactly once
4646
/// * Must not be dropped while in use from another process
4747
unsafe fn try_wait(&self) -> Result<bool, ListenerWaitError>;
4848

@@ -54,7 +54,7 @@ pub trait SignalMechanism: Send + Sync + Debug {
5454
/// it returns [`ListenerWaitError::InterruptSignal`].
5555
///
5656
/// # Safety
57-
/// * [`SignalMechanism::init()`] must be called before
57+
/// * [`SignalMechanism::init()`] must have been called exactly once
5858
/// * Must not be dropped while in use from another process
5959
unsafe fn timed_wait(&self, timeout: Duration) -> Result<bool, ListenerWaitError>;
6060

@@ -64,7 +64,7 @@ pub trait SignalMechanism: Send + Sync + Debug {
6464
/// it returns [`ListenerWaitError::InterruptSignal`].
6565
///
6666
/// # Safety
67-
/// * [`SignalMechanism::init()`] must called before
67+
/// * [`SignalMechanism::init()`] must have been called exactly once
6868
/// * Must not be dropped while in use from another process
6969
unsafe fn blocking_wait(&self) -> Result<(), ListenerWaitError>;
7070
}

0 commit comments

Comments
 (0)