bqskit icon indicating copy to clipboard operation
bqskit copied to clipboard

“Lazy Map” capability for the BQSKit runtime

Open WolfLink opened this issue 7 months ago • 3 comments

I’d like the ability to perform a “lazy map”, meaning to have a RuntimeFuture to which I can submit more tasks. Here’s an example scenario where this would be useful:

  1. I start an asynchronous task A
  2. I perform some other code
  3. I start an asynchronous task B
  4. I wait for a result from either A or B (whichever finishes first)
  5. I cancel the other task (or all such other tasks if you expand this pattern beyond 2 tasks).

I imagine the code looking something like this:

lazy_map = get_runtime().lazy_map()
lazy_map.submit(A)
# other code
lazy_map.submit(B)
result = await lazy_map
lazy_map.cancel()

Another way to do this would be a way to await a list of futures

WolfLink avatar Jul 17 '24 16:07 WolfLink