Skip to content

Commit 4d8ab92

Browse files
committed
zephyr: work: futures: Ensure JoinHandle is Send when it can be
The join handle can bew used across multiple threads, as long as the output of the Future is Send. Signed-off-by: David Brown <[email protected]>
1 parent 82ee349 commit 4d8ab92

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

zephyr/src/work/futures.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,15 @@ pub struct JoinHandle<F: Future> {
190190
answer: Arc<Answer<F::Output>>,
191191
}
192192

193+
// SAFETY: The join handle can be Send as long as the Output is send. It does not depend on the
194+
// Future being send.
195+
unsafe impl<F> Send for JoinHandle<F>
196+
where
197+
F: Future,
198+
F::Output: Send
199+
{
200+
}
201+
193202
impl<F: Future + Send> JoinHandle<F> {
194203
/// Construct new [`JoinHandle`] that runs on a specified [`WorkQueue`].
195204
fn new(builder: &WorkBuilder, future: F) -> Self {

0 commit comments

Comments
 (0)