Open aschaeffer opened 1 year ago
This may take a while until support for async closures land in rust:
type Subscriber<'a, Sig> = (u128, dyn FnMut(&Sig) + Send + 'a);
subscribers_mut.par_iter_mut().for_each(|sub| sub.1(signal));
type Subscriber<'a, Sig> = (u128, async dyn FnMut(&Sig) + Send + 'a);
let mut tasks = Vec::new();
for subscriber in subscribers_mut.iter_mut() {
tokio::spawn(async {
tasks.push(subscriber(signal).await);
}
}
tasks.join_all();
Problem
Idea
The GraphQL API is async already. If the reactive streams would be async, it would be possible to avoid blocking completely and further increase performance.
Research tasks
tokio main
This may work or not - the goal is to get an idea if it would be possible.