Skip to main content

Mojo function

parallelize

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

Executes func(0) ... func(num_work_items-1) as sub-tasks in parallel, 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.

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

Executes func(0) ... func(num_work_items-1) as sub-tasks in parallel, 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.
  • num_workers (Int): The number of workers to use for execution.