Skip to content

Commit b2ecad2

Browse files
authored
Use TaskCreationOptions.RunContinuationsAsynchronously (#662)
1 parent 044c360 commit b2ecad2

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

‎src/FSharpPlus/Extensions/Task.fs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ module Task =
8282
| Faulted exn , _ -> FromExceptions exn
8383
| Canceled , _ -> canceled
8484
else
85-
let tcs = TaskCompletionSource<'U> ()
85+
let tcs = TaskCompletionSource<'U> TaskCreationOptions.RunContinuationsAsynchronously
8686

8787
match task1.Status, task2.Status with
8888
| TaskStatus.Canceled, _ -> tcs.SetCanceled ()
@@ -115,7 +115,7 @@ module Task =
115115
| _ , _ , Faulted exn -> FromExceptions exn
116116
| _ , _ , Canceled -> canceled
117117
else
118-
let tcs = TaskCompletionSource<'U> ()
118+
let tcs = TaskCompletionSource<'U> TaskCreationOptions.RunContinuationsAsynchronously
119119
match task1.Status, task2.Status, task3.Status with
120120
| TaskStatus.Canceled, _ , _ -> tcs.SetCanceled ()
121121
| TaskStatus.Faulted , _ , _ -> tcs.SetException (Unchecked.nonNull task1.Exception).InnerExceptions
@@ -242,7 +242,7 @@ module Task =
242242
| Faulted exn , _ -> FromExceptions exn
243243
| Canceled , _ -> canceled
244244
else
245-
let tcs = TaskCompletionSource<'U> ()
245+
let tcs = TaskCompletionSource<'U> TaskCreationOptions.RunContinuationsAsynchronously
246246
match f.Status, x.Status with
247247
| TaskStatus.Canceled, _ -> tcs.SetCanceled ()
248248
| TaskStatus.Faulted, _ -> tcs.SetException (Unchecked.nonNull f.Exception).InnerExceptions

‎src/FSharpPlus/Extensions/ValueTask.fs‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ module ValueTask =
8383
| Faulted exn , _ -> FromExceptions exn
8484
| Canceled , _ -> canceled
8585
else
86-
let tcs = TaskCompletionSource<'U> ()
86+
let tcs = TaskCompletionSource<'U> TaskCreationOptions.RunContinuationsAsynchronously
8787
if task1.IsCanceled then tcs.SetCanceled ()
8888
elif task1.IsFaulted then tcs.SetException (Unchecked.nonNull (task1.AsTask().Exception)).InnerExceptions
8989
elif task2.IsCanceled then tcs.SetCanceled ()
@@ -110,7 +110,7 @@ module ValueTask =
110110
| _ , _ , Faulted exn -> FromExceptions exn
111111
| _ , _ , Canceled -> canceled
112112
else
113-
let tcs = TaskCompletionSource<'U> ()
113+
let tcs = TaskCompletionSource<'U> TaskCreationOptions.RunContinuationsAsynchronously
114114
if task1.IsCanceled then tcs.SetCanceled ()
115115
elif task1.IsFaulted then tcs.SetException (Unchecked.nonNull (task1.AsTask().Exception)).InnerExceptions
116116
elif task2.IsCanceled then tcs.SetCanceled ()
@@ -227,7 +227,7 @@ module ValueTask =
227227
| Faulted exn , _ -> FromExceptions exn
228228
| Canceled , _ -> canceled
229229
else
230-
let tcs = TaskCompletionSource<'U> ()
230+
let tcs = TaskCompletionSource<'U> TaskCreationOptions.RunContinuationsAsynchronously
231231
if f.IsCanceled then tcs.SetCanceled ()
232232
elif f.IsFaulted then tcs.SetException (Unchecked.nonNull (f.AsTask().Exception)).InnerExceptions
233233
elif x.IsCanceled then tcs.SetCanceled ()
@@ -343,4 +343,4 @@ module ValueTask =
343343
/// <returns>A ValueTask that is completed unsuccessfully with the specified exception.</returns>
344344
let raise<'T> (exn: exn) : ValueTask<'T> = ValueTask.FromException<'T> exn
345345

346-
#endif
346+
#endif

0 commit comments

Comments
 (0)