Exclude Send + Sync from async

Using this macro causes the surrounding asynchronous context to implement !Send. I used it in my cross-platform timer API and I like to ensure everything is non concurrent.

/// Marks asynchronous code as `!Send`.
pub(crate) macro no_send {
    () => {
        futures::future::ready(std::marker::PhantomData::<*const ()>::default()).await;

I'm in inertia with my Agera SDK project, but I'm wondering if I can implement !Sync to the surrounding async?

Does Sync ever matter? You can't access any part of an opaque Future through a & reference.

1 Like

You can use a test like the following to ensure that Send and Sync have the value you want:

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.