otp icon indicating copy to clipboard operation
otp copied to clipboard

Add `await_many` and related functions

Open joakin opened this issue 1 year ago • 1 comments

For running many tasks in parallel, it is complicated to get a solid solution, for example:

pub fn parallel(make_tasks: List(fn() -> a), timeout: Int) -> List(a) {
  make_tasks
  |> list.map(fn(make_task) { task.async(make_task) })
  |> list.map(fn(t) { task.await(t, timeout) })
}

Works but the timeouts will be run in sequence which is not what you really want.

It has been mentioned in discord a few times too:

  • https://discord.com/channels/768594524158427167/768594524158427170/1287851279925907509
  • https://discord.com/channels/768594524158427167/768594524158427170/1079034165024014388

joakin avatar Sep 24 '24 09:09 joakin

Some of these functions have been added in v0.13

lpil avatar Oct 31 '24 16:10 lpil

Since the task module has been removed, this issue should be closed or moved.

benev0 avatar Oct 08 '25 05:10 benev0