At the moment, the source of the function is recorded so that this guarantee is respected. Looking at control.fs around line # 1300 for definition, we can see that the function that puts the results in the output array is
let recordSuccess i res = results.[i] <- res; finishTask(Interlocked.Decrement count)
this function is called in this segment
tasks |> Array.iteri (fun ip -> queueAsync innerCTS.Token
where tasks has the original tasks in sorted order. This ensures that the output list is in the same order as the input.
UPDATE
The specification, at least, implies that the order is fixed - it contains this code:
let rec fib x = if x < 2 then 1 else fib(x-1) + fib(x-2) let fibs = Async.Parallel [ for i in 0..40 -> async { return fib(i) } ] |> Async.RunSynchronously printfn "The Fibonacci numbers are %A" fibs //I changed this line to be accurate System.Console.ReadKey(true)
If the specification did not guarantee the order of output, this code would be incorrect.
source share