someguynamedjosh/ouroboros

Is it safe and sound to add `Send` bound on returned future of async builder?

skyzh opened this issue · 2 comments

skyzh commented

https://github.com/joshua-maros/ouroboros/blob/6bbf159e5bf70d1de8a8e66a42b3ee318c6fadd8/ouroboros_macro/src/info_structures.rs#L248

It seems that the Boxed future doesn't have Send bound, which means the the AsyncBuilder cannot be used in multi-thread tokio runtime. Does it look good to:

  • add a Send bound by default to those futures?
  • ... or use some parameters to control the behavior? Like #[self_referencing(Send)]
  • ... or use impl Future<Output = XXX> as the return value so that the compiler can infer the original Send bound of the future?

Thanks for investigating into this! If possible, I can also help implement one of these solutions.

Unfortunately, I don't know enough about the internals to know if such a thing would be safe.

skyzh commented

Unfortunately, I don't know enough about the internals to know if such a thing would be safe.

Thanks for your response! Let’s leave this issue open and see if anyone could shed some lights on it…