Skip to content
FutureBlitz

    Install

    Import std.concurrent.parallel

    ParallelForEach

    std.concurrent.parallel

    function

    Public Function ParallelForEach<T: Sendable>(items: T[], action: Sendable Func(T))

    Calls action with each item, on the pool at once, in no order.

    Examples

    Global total = Atomic<Int>(0)
    
    Function AddUp(n: Int)
        total.Add(n)
    End Function
    
    ParallelForEach([1, 2, 3, 4], AddUp)
    Expect(total.Load() == 10)

    std/concurrent/parallel.fb, line 33

    Report an issue with this page or with FutureBlitz on GitHub.