How often do you want non-send futures?

I think it's a reasonable question whether there are other traits that would want to be the default -- but there are some special things about Send.

  • We know that some futures need to be send but others don't -- and imposing Send involves limiting the sorts of things the future can do (i.e., it can't access a shared Cell or RefCell, use an Rc, etc).
  • The Sync trait says that something can be safely shared across threads (as opposed to transferred from thread to thread). But sharing a future across threads doesn't make sense: the poll method on Future is &mut self, so you couldn't do anything with a shared future.
  • Other traits like Debug would probably be useful, but as @withoutboats noted elsewhere, we would ideally implement these uniformly for all async fns, and there isn't really a downside to implementing them (but doing this well would require some form of specialization, I imagine, so that we can have a fallback).
4 Likes