Skip to content

Commit f0c2e09

Browse files
committed
Fix all todos that can be addressed for now
Signed-off-by: Michael X. Grey <[email protected]>
1 parent 1d8c468 commit f0c2e09

File tree

4 files changed

+45
-10
lines changed

4 files changed

+45
-10
lines changed

rclrs/src/subscription/into_async_subscription_callback.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,13 @@ use std::future::Future;
99

1010
/// A trait for async callbacks of subscriptions.
1111
///
12-
// TODO(@mxgrey): Add a description of what callback signatures are supported
12+
/// Async subscription callbacks support six signatures:
13+
/// - [`FnMut`] ( `Message` ) -> impl [`Future`][1]<Output=()>
14+
/// - [`FnMut`] ( `Message`, [`MessageInfo`][2] ) -> impl [`Future`][1]<Output=()>
15+
/// - [`FnMut`] ( [`Box`]<`Message`> ) -> impl [`Future`][1]<Output=()>
16+
/// - [`FnMut`] ( [`Box`]<`Message`>, [`MessageInfo`][2] ) -> impl [`Future`][1]<Output=()>
17+
/// - [`FnMut`] ( [`ReadOnlyLoanedMessage`][3]<`Message`> ) -> impl [`Future`][1]<Output=()>
18+
/// - [`FnMut`] ( [`ReadOnlyLoanedMessage`][3]<`Message`>, [`MessageInfo`][2] ) -> impl [`Future`][1]<Output=()>
1319
pub trait IntoAsyncSubscriptionCallback<T, Args>: Send + 'static
1420
where
1521
T: Message,

rclrs/src/subscription/into_node_subscription_callback.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,14 @@ use crate::{
77
use std::sync::Arc;
88

99
/// A trait for regular callbacks of subscriptions.
10-
//
11-
// TODO(@mxgrey): Add a description of what callbacks signatures are supported
10+
///
11+
/// Subscription callbacks support six signatures:
12+
/// - [`Fn`] ( `Message` )
13+
/// - [`Fn`] ( `Message`, [`MessageInfo`][1] )
14+
/// - [`Fn`] ( [`Box`]<`Message`> )
15+
/// - [`Fn`] ( [`Box`]<`Message`>, [`MessageInfo`][1] )
16+
/// - [`Fn`] ( [`ReadOnlyLoanedMessage`][2]<`Message`> )
17+
/// - [`Fn`] ( [`ReadOnlyLoanedMessage`][2]<`Message`>, [`MessageInfo`][1] )
1218
pub trait IntoNodeSubscriptionCallback<T, Args>: Send + 'static
1319
where
1420
T: Message,

rclrs/src/subscription/into_worker_subscription_callback.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,20 @@ use rosidl_runtime_rs::Message;
33
use crate::{ReadOnlyLoanedMessage, MessageInfo, AnySubscriptionCallback, WorkerSubscriptionCallback};
44

55
/// A trait for callbacks of subscriptions that run on a worker.
6-
//
7-
// TODO(@mxgrey): Add a description of what callbacks signatures are supported
6+
///
7+
/// Worker Subscription callbacks support twelve signatures:
8+
/// - [`FnMut`] ( `Message` )
9+
/// - [`FnMut`] ( `Message`, [`MessageInfo`][4] )
10+
/// - [`FnMut`] ( `&mut Payload`, `Message` )
11+
/// - [`FnMut`] ( `&mut Payload`, `Message`, [`MessageInfo`][4] )
12+
/// - [`FnMut`] ( [`Box`]<`Message`> )
13+
/// - [`FnMut`] ( [`Box`]<`Message`>, [`MessageInfo`][4] )
14+
/// - [`FnMut`] ( `&mut Payload`, [`Box`]<`Message`> )
15+
/// - [`FnMut`] ( `&mut Payload`, [`Box`]<`Message`>, [`MessageInfo`][4] )
16+
/// - [`FnMut`] ( [`ReadOnlyLoanedMessage`][5]<`Message`> )
17+
/// - [`FnMut`] ( [`ReadOnlyLoanedMessage`][5]<`Message`>, [`MessageInfo`][4] )
18+
/// - [`FnMut`] ( `&mut Payload`, [`ReadOnlyLoanedMessage`][5]<`Message`> )
19+
/// - [`FnMut`] ( `&mut Payload`, [`ReadOnlyLoanedMessage`][5]<`Message`>, [`MessageInfo`][4] )
820
pub trait IntoWorkerSubscriptionCallback<T, Payload, Args>: Send + 'static
921
where
1022
T: Message,

rclrs/src/wait_set/wait_set_runner.rs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ use std::{
1111

1212
use crate::{
1313
Context, Promise, RclrsError, WaitSet, Waitable, GuardCondition, ExecutorWorkerOptions,
14-
PayloadTask, WeakActivityListener, ActivityListenerCallback, RclReturnCode,
14+
PayloadTask, WeakActivityListener, ActivityListenerCallback, RclReturnCode, log_debug,
15+
log_fatal,
1516
};
1617

1718
/// This is a utility class that executors can use to easily run and manage
@@ -107,8 +108,14 @@ impl WaitSetRunner {
107108
let (sender, promise) = channel();
108109
std::thread::spawn(move || {
109110
let result = self.run_blocking(conditions);
110-
// TODO(@mxgrey): Log any error here when logging becomes available
111-
sender.send((self, result)).ok();
111+
if let Err(_) = sender.send((self, result)) {
112+
// This is a debug log because this is a normal thing to occur
113+
// when an executor is winding down.
114+
log_debug!(
115+
"rclrs.wait_set_runner.run",
116+
"Unable to return the wait set runner from an async run"
117+
);
118+
}
112119
});
113120

114121
promise
@@ -134,8 +141,12 @@ impl WaitSetRunner {
134141
new_waitables.push(new_waitable);
135142
}
136143
if !new_waitables.is_empty() {
137-
// TODO(@mxgrey): Log any error here when logging becomes available
138-
self.wait_set.add(new_waitables).ok();
144+
if let Err(err) = self.wait_set.add(new_waitables) {
145+
log_fatal!(
146+
"rclrs.wait_set_runner.run_blocking",
147+
"Failed to add an item to the wait set: {err}",
148+
);
149+
}
139150
}
140151

141152
while let Ok(Some(task)) = self.task_receiver.try_next() {

0 commit comments

Comments
 (0)