@@ -10,7 +10,7 @@ module Async =
10
10
let map f x = async.Bind ( x, async.Return << f)
11
11
12
12
/// <summary>Creates an async workflow from two workflows 'x' and 'y', mapping its results with 'f'.</summary>
13
- /// <remarks>Workflows are run in sequence. For parallel use pmap2</remarks>
13
+ /// <remarks>Workflows are run in sequence, for parallel use pmap2. </remarks>
14
14
/// <param name="f">The mapping function.</param>
15
15
/// <param name="x">First async workflow.</param>
16
16
/// <param name="y">Second async workflow.</param>
@@ -37,7 +37,7 @@ module Async =
37
37
#endif
38
38
39
39
/// <summary>Creates an async workflow from three workflows 'x', 'y' and 'z', mapping its results with 'f'.</summary>
40
- /// <remarks>Workflows are run in sequence. For parallel use pmap3</remarks>
40
+ /// <remarks>Workflows are run in sequence, for parallel use pmap3. </remarks>
41
41
/// <param name="f">The mapping function.</param>
42
42
/// <param name="x">First async workflow.</param>
43
43
/// <param name="y">Second async workflow.</param>
@@ -68,6 +68,43 @@ module Async =
68
68
return f x' y' z' }
69
69
#endif
70
70
71
+ /// <summary>Creates an async workflow from two workflows 'x' and 'y', mapping its results with 'f'.</summary>
72
+ /// <remarks>Similar to map2 but workflows are run in parallel.</remarks>
73
+ /// <param name="f">The mapping function.</param>
74
+ /// <param name="x">First async workflow.</param>
75
+ /// <param name="y">Second async workflow.</param>
76
+ #if FABLE_ COMPILER
77
+ let pmap2 f x y = map2 f x y
78
+ #else
79
+ let pmap2 f x y = async {
80
+ let! ct = Async.CancellationToken
81
+ let x = Async.StartImmediateAsTask ( x, ct)
82
+ let y = Async.StartImmediateAsTask ( y, ct)
83
+ let! x ' = Async.AwaitTask x
84
+ let! y ' = Async.AwaitTask y
85
+ return f x' y' }
86
+ #endif
87
+
88
+ /// <summary>Creates an async workflow from three workflows 'x', 'y' and 'z', mapping its results with 'f'.</summary>
89
+ /// <remarks>Similar to map3 but workflows are run in parallel.</remarks>
90
+ /// <param name="f">The mapping function.</param>
91
+ /// <param name="x">First async workflow.</param>
92
+ /// <param name="y">Second async workflow.</param>
93
+ /// <param name="z">third async workflow.</param>
94
+ #if FABLE_ COMPILER
95
+ let pmap3 f x y z = map3 f x y z
96
+ #else
97
+ let pmap3 f x y z = async {
98
+ let! ct = Async.CancellationToken
99
+ let x = Async.StartImmediateAsTask ( x, ct)
100
+ let y = Async.StartImmediateAsTask ( y, ct)
101
+ let z = Async.StartImmediateAsTask ( z, ct)
102
+ let! x ' = Async.AwaitTask x
103
+ let! y ' = Async.AwaitTask y
104
+ let! z ' = Async.AwaitTask z
105
+ return f x' y' z' }
106
+ #endif
107
+
71
108
/// <summary>Creates an async workflow from two workflows 'x' and 'y', tupling its results.</summary>
72
109
let zip x y = async {
73
110
let! a = x
0 commit comments