Skip to main content

Mojo function

sync_parallelize

sync_parallelize[origins: origin.set, //, func: fn(Int) capturing -> None](num_work_items: Int)

Executes func(0) ... func(num_work_items-1) as parallel sub-tasks, and returns when all are complete.

Parameters:

  • origins (origin.set): The capture origins.
  • func (fn(Int) capturing -> None): The function to invoke.

Args:

  • num_work_items (Int): Number of parallel tasks.

sync_parallelize[origins: origin.set, //, func: fn(Int) raises capturing -> None](num_work_items: Int)

Executes func(0) ... func(num_work_items-1) as parallel sub-tasks, and returns when all are complete.

TODO: Currently exceptions raised by func will cause a trap rather than be propagated back to the caller.

Parameters:

  • origins (origin.set): The capture origins.
  • func (fn(Int) raises capturing -> None): The function to invoke.

Args:

  • num_work_items (Int): Number of parallel tasks.