Skip to content

Commit 59c59c9

Browse files
committed
Async.Parallel tuple
1 parent 34bfd84 commit 59c59c9

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

src/FSharpx.Async/Async.fs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,26 @@ module AsyncExtensions =
4040
{ new IDisposable with
4141
member x.Dispose() = ct.Cancel() }
4242

43+
/// Creates an async computations which runs the specified computations
44+
/// in parallel and returns their results.
45+
static member Parallel(a:Async<'a>, b:Async<'b>) : Async<'a * 'b> = async {
46+
let! a = a |> Async.StartChild
47+
let! b = b |> Async.StartChild
48+
let! a = a
49+
let! b = b
50+
return a,b }
51+
52+
/// Creates an async computations which runs the specified computations
53+
/// in parallel and returns their results.
54+
static member Parallel(a:Async<'a>, b:Async<'b>, c:Async<'c>) : Async<'a * 'b * 'c> = async {
55+
let! a = a |> Async.StartChild
56+
let! b = b |> Async.StartChild
57+
let! c = c |> Async.StartChild
58+
let! a = a
59+
let! b = b
60+
let! c = c
61+
return a,b,c }
62+
4363
/// An async computation which does nothing.
4464
static member inline unit = AsyncOps.unit
4565

0 commit comments

Comments
 (0)