Skip to content

Commit f1147f9

Browse files
committed
[eclipse-iceoryx#139] Introduce signal and id_tracker traits
1 parent a018d3b commit f1147f9

File tree

4 files changed

+43
-0
lines changed

4 files changed

+43
-0
lines changed

iceoryx2-cal/src/event/id_tracker.rs

Whitespace-only changes.
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright (c) 2024 Contributors to the Eclipse Foundation
2+
//
3+
// See the NOTICE file(s) distributed with this work for additional
4+
// information regarding copyright ownership.
5+
//
6+
// This program and the accompanying materials are made available under the
7+
// terms of the Apache Software License 2.0 which is available at
8+
// https://www.apache.org/licenses/LICENSE-2.0, or the MIT license
9+
// which is available at https://opensource.org/licenses/MIT.
10+
//
11+
// SPDX-License-Identifier: Apache-2.0 OR MIT
12+
13+
use super::TriggerId;
14+
15+
pub trait IdTracker<Id: TriggerId> {
16+
fn set(&self, id: Id);
17+
fn reset_next(&self) -> Id;
18+
fn reset_all<F: FnMut(Id)>(&self, callback: F);
19+
}

iceoryx2-cal/src/event/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
//
1111
// SPDX-License-Identifier: Apache-2.0 OR MIT
1212

13+
pub mod id_tracker;
1314
pub mod process_local;
15+
pub mod signal;
1416
pub mod unix_datagram_socket;
1517

1618
use std::{fmt::Debug, time::Duration};

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

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright (c) 2024 Contributors to the Eclipse Foundation
2+
//
3+
// See the NOTICE file(s) distributed with this work for additional
4+
// information regarding copyright ownership.
5+
//
6+
// This program and the accompanying materials are made available under the
7+
// terms of the Apache Software License 2.0 which is available at
8+
// https://www.apache.org/licenses/LICENSE-2.0, or the MIT license
9+
// which is available at https://opensource.org/licenses/MIT.
10+
//
11+
// SPDX-License-Identifier: Apache-2.0 OR MIT
12+
13+
use std::time::Duration;
14+
15+
use super::{ListenerWaitError, NotifierNotifyError};
16+
17+
pub trait SignalMechanism {
18+
fn notify(&self) -> Result<(), NotifierNotifyError>;
19+
fn try_wait(&self) -> Result<(), ListenerWaitError>;
20+
fn timed_wait(&self, timeout: Duration) -> Result<(), ListenerWaitError>;
21+
fn blocking_wait(&self) -> Result<(), ListenerWaitError>;
22+
}

0 commit comments

Comments
 (0)