Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call multiple lookup operations async #166

Open
eozturk1 opened this issue Mar 9, 2022 · 1 comment
Open

Call multiple lookup operations async #166

eozturk1 opened this issue Mar 9, 2022 · 1 comment

Comments

@eozturk1
Copy link
Contributor

eozturk1 commented Mar 9, 2022

To improve the efficiency of bulk/multi lookups, we could call lookups async and await on the results of all lookups -- rather than awaiting on them individually.

@slawlor
Copy link
Contributor

slawlor commented Mar 9, 2022

Pulled from comment in PR #163

use futures::future;

// generate your vector of individual tasks by spawning them on green threads
// but you need to clone "self" in order to apply on different threads, which will
// shard the data-access pointer and cache pointers, etc to yield individual Directory<_>
// instances on each thread
let tasks = proofs_to_generate.into_iter().map(|proof| {
  let self_clone = self.clone();
  tokio::spawn(async move { self_clone.lookup(proof).await })
}

let outputs = future::try_join_all(tasks).await?;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants