2 ms·
There should be a way to define an async executor API that works like Crossbeam's scoped threads API, so that the executor lives inside a fixed scope and is gua
by oconnor663 6y ago
There should be a way to define an async executor API that works like Crossbeam's scoped threads API, so that the executor lives inside a fixed scope and is guaranteed to clean up any outstanding tasks before the end of that scope. Then it would be safe to accept references to longer-lived values on the stack. My guess is that there's not much demand for such an API outside of toy examples, though. (Does anyone use `crossbeam::scope` in production? It's a beautiful and important concept, but it seems to occupy an awkward performance point of "I care enough to worry about heap allocations, but not enough to use a thread pool.") EDIT: Ah, just saw GolDDranks' similar comment.
- dathinab 6y agoThere are, but you often run into limitations in praxis. For example you can take a look at tokio::LocalSet::{block_on,run_until} which require neither 'static nor Send or Sync. But then spawn_local does require 'static. Same is true for smol where we have smol::block_on, smol::{Executor,LocalExecutor}::run and here too we have the limitation that calling spawn on a LocalExecutor requires static.