diff --git a/benchmarks/AsyncResultCE.fs b/benchmarks/AsyncResultCE.fs index ff36b5ec..c2bb6c34 100644 --- a/benchmarks/AsyncResultCE.fs +++ b/benchmarks/AsyncResultCE.fs @@ -1,4 +1,4 @@ -namespace FsToolkit.ErrorHandling.Benchmarks +namespace FsToolkit.ErrorHandling.Benchmarks open System open BenchmarkDotNet @@ -54,7 +54,7 @@ module AsyncResultCEExtensions = /// Method lets us transform data types into our internal representation. /// member inline _.Source(result: Result<_, _>) : Async> = Async.singleton result - let rec fib n = + let rec fib n = if n < 2L then n else fib (n - 1L) + fib (n - 2L) @@ -62,14 +62,14 @@ module AsyncResultCEExtensions = if n < 0L then return Error "No" elif n < 2L then return Ok n - elif n < level then + elif n < level then return Ok (fib n) else let! n2a = afib (n-2L, level) |> Async.StartChild let! n1 = afib (n-1L, level) let! n2 = n2a match n1, n2 with - | Ok n1, Ok n2 -> + | Ok n1, Ok n2 -> return Ok (n2 + n1) | Error e, _ | _, Error e -> return Error e @@ -81,11 +81,11 @@ module AsyncResultCEExtensions = [] member this.afib() = - afib(10,5) - |> Async.StartAsTask - + afib(10,5) + |> Async.StartImmediateAsTask + [] - member this.Result_Normal_Bind_CE() = + member this.Result_Normal_Bind_CE() = let action () = asyncResult { let! a = Ok 10 let! b = Ok 5 @@ -93,11 +93,11 @@ module AsyncResultCEExtensions = return c } action () - |> Async.StartAsTask - + |> Async.StartImmediateAsTask + [] - member this.Result_Alt_Inlined_Bind_CE () = + member this.Result_Alt_Inlined_Bind_CE () = let action () = asyncResultInlinedIfLambda { let! a = Ok 10 let! b = Ok 5 @@ -105,4 +105,4 @@ module AsyncResultCEExtensions = return c } action () - |> Async.StartAsTask \ No newline at end of file + |> Async.StartImmediateAsTask diff --git a/src/FsToolkit.ErrorHandling.IcedTasks/CancellableTaskResultCE.fs b/src/FsToolkit.ErrorHandling.IcedTasks/CancellableTaskResultCE.fs index 53b5eb29..801476f5 100644 --- a/src/FsToolkit.ErrorHandling.IcedTasks/CancellableTaskResultCE.fs +++ b/src/FsToolkit.ErrorHandling.IcedTasks/CancellableTaskResultCE.fs @@ -681,7 +681,7 @@ module CancellableTaskResultCE = } static member inline AsCancellableTaskResult(computation: Async<'T>) = - fun ct -> Async.StartAsTask(computation, cancellationToken = ct) + fun ct -> Async.StartImmediateAsTask(computation, cancellationToken = ct) type CancellableTaskResultBuilderBase with diff --git a/src/FsToolkit.ErrorHandling.TaskResult/TaskOptionCE.fs b/src/FsToolkit.ErrorHandling.TaskResult/TaskOptionCE.fs index 7c120dfd..c087970d 100644 --- a/src/FsToolkit.ErrorHandling.TaskResult/TaskOptionCE.fs +++ b/src/FsToolkit.ErrorHandling.TaskResult/TaskOptionCE.fs @@ -132,7 +132,7 @@ module TaskOptionCE = /// member inline _.Source(async: Async<_ option>) : Task<_ option> = async - |> Async.StartAsTask + |> Async.StartImmediateAsTask /// /// Method lets us transform data types into our internal representation. @@ -268,7 +268,7 @@ module TaskOptionCE = /// member inline _.Source(async: Async<_ option>) : Task<_ option> = async - |> Async.StartAsTask + |> Async.StartImmediateAsTask /// /// Method lets us transform data types into our internal representation. @@ -360,7 +360,7 @@ module TaskOptionCEExtensions = FSharp.Control.Tasks.Affine.task { let! o = a - |> Async.StartAsTask + |> Async.StartImmediateAsTask return Some o } @@ -421,7 +421,7 @@ module TaskOptionCEExtensions = FSharp.Control.Tasks.NonAffine.task { let! o = a - |> Async.StartAsTask + |> Async.StartImmediateAsTask return Some o } @@ -639,7 +639,7 @@ type TaskOptionBuilderBase() = member inline this.Source(computation: Async<'T option>) : TaskOption<'T> = computation - |> Async.StartAsTask + |> Async.StartImmediateAsTask member inline this.Source(taskOption: TaskOption<'T>) : TaskOption<'T> = taskOption @@ -1039,6 +1039,6 @@ module TaskOptionCEExtensionsMediumPriority = member inline this.Source(computation: Async<'T>) : TaskOption<'T> = computation |> Async.map Some - |> Async.StartAsTask + |> Async.StartImmediateAsTask #endif diff --git a/src/FsToolkit.ErrorHandling.TaskResult/TaskResult.fs b/src/FsToolkit.ErrorHandling.TaskResult/TaskResult.fs index 28d5b258..85be1364 100644 --- a/src/FsToolkit.ErrorHandling.TaskResult/TaskResult.fs +++ b/src/FsToolkit.ErrorHandling.TaskResult/TaskResult.fs @@ -24,7 +24,7 @@ module TaskResult = let inline ofAsync aAsync = aAsync |> Async.Catch - |> Async.StartAsTask + |> Async.StartImmediateAsTask |> Task.map Result.ofChoice let inline retn x = diff --git a/src/FsToolkit.ErrorHandling.TaskResult/TaskResultCE.fs b/src/FsToolkit.ErrorHandling.TaskResult/TaskResultCE.fs index 961192d7..cdccae01 100644 --- a/src/FsToolkit.ErrorHandling.TaskResult/TaskResultCE.fs +++ b/src/FsToolkit.ErrorHandling.TaskResult/TaskResultCE.fs @@ -140,7 +140,7 @@ module TaskResultCE = /// member inline _.Source(result: Async>) : Task> = result - |> Async.StartAsTask + |> Async.StartImmediateAsTask /// /// Method lets us transform data types into our internal representation. @@ -286,7 +286,7 @@ module TaskResultCE = /// member inline _.Source(result: Async>) : Task> = result - |> Async.StartAsTask + |> Async.StartImmediateAsTask /// /// Method lets us transform data types into our internal representation. @@ -349,7 +349,7 @@ module TaskResultCEExtensions = FSharp.Control.Tasks.Affine.task { let! r = asyncComputation - |> Async.StartAsTask + |> Async.StartImmediateAsTask return Ok r } @@ -426,7 +426,7 @@ module TaskResultCEExtensions = FSharp.Control.Tasks.NonAffine.task { let! r = asyncComputation - |> Async.StartAsTask + |> Async.StartImmediateAsTask return Ok r } @@ -695,7 +695,7 @@ type TaskResultBuilderBase() = member inline _.Source(result: Async>) : Task> = result - |> Async.StartAsTask + |> Async.StartImmediateAsTask member inline _.Source(t: ValueTask>) : Task> = task { return! t } member inline _.Source(result: Result<_, _>) : Task> = Task.singleton result @@ -1064,6 +1064,6 @@ module TaskResultCEExtensionsMediumPriority = member inline this.Source(computation: Async<'T>) : TaskResult<'T, 'Error> = computation |> Async.map Ok - |> Async.StartAsTask + |> Async.StartImmediateAsTask #endif diff --git a/tests/FsToolkit.ErrorHandling.TaskResult.Tests/Expecto.fs b/tests/FsToolkit.ErrorHandling.TaskResult.Tests/Expecto.fs index c1fd2bf4..e61f0ef6 100644 --- a/tests/FsToolkit.ErrorHandling.TaskResult.Tests/Expecto.fs +++ b/tests/FsToolkit.ErrorHandling.TaskResult.Tests/Expecto.fs @@ -66,4 +66,4 @@ type Expect = static member CancellationRequested(operation: Task<_>) = Expect.CancellationRequested(Async.AwaitTask operation) - |> Async.StartAsTask + |> Async.StartImmediateAsTask diff --git a/tests/FsToolkit.ErrorHandling.TaskResult.Tests/List.fs b/tests/FsToolkit.ErrorHandling.TaskResult.Tests/List.fs index 78ba6c29..004426c9 100644 --- a/tests/FsToolkit.ErrorHandling.TaskResult.Tests/List.fs +++ b/tests/FsToolkit.ErrorHandling.TaskResult.Tests/List.fs @@ -19,11 +19,11 @@ let userId4 = Guid.NewGuid() let notifyNewPostSuccess x = notifyNewPostSuccess x - >> Async.StartAsTask + >> Async.StartImmediateAsTask let notifyNewPostFailure x = notifyNewPostFailure x - >> Async.StartAsTask + >> Async.StartImmediateAsTask [] let traverseTaskResultMTests = diff --git a/tests/FsToolkit.ErrorHandling.TaskResult.Tests/TaskOption.fs b/tests/FsToolkit.ErrorHandling.TaskResult.Tests/TaskOption.fs index e0d9f7cd..3a3f7049 100644 --- a/tests/FsToolkit.ErrorHandling.TaskResult.Tests/TaskOption.fs +++ b/tests/FsToolkit.ErrorHandling.TaskResult.Tests/TaskOption.fs @@ -23,15 +23,15 @@ let runTaskSync (task: Task<_>) = task.Result let createPostSome = createPostSome - >> Async.StartAsTask + >> Async.StartImmediateAsTask let getFollowersSome = getFollowersSome - >> Async.StartAsTask + >> Async.StartImmediateAsTask let allowedToPostOptional = allowedToPostOptional - >> Async.StartAsTask + >> Async.StartImmediateAsTask let mapTests = diff --git a/tests/FsToolkit.ErrorHandling.TaskResult.Tests/TaskResult.fs b/tests/FsToolkit.ErrorHandling.TaskResult.Tests/TaskResult.fs index a7b24889..f192f6e7 100644 --- a/tests/FsToolkit.ErrorHandling.TaskResult.Tests/TaskResult.fs +++ b/tests/FsToolkit.ErrorHandling.TaskResult.Tests/TaskResult.fs @@ -18,23 +18,23 @@ let runTaskSync (task: Task<_>) = task.Result let createPostSuccess = createPostSuccess - >> Async.StartAsTask + >> Async.StartImmediateAsTask let createPostFailure = createPostFailure - >> Async.StartAsTask + >> Async.StartImmediateAsTask let getFollowersSuccess = getFollowersSuccess - >> Async.StartAsTask + >> Async.StartImmediateAsTask let getFollowersFailure = getFollowersFailure - >> Async.StartAsTask + >> Async.StartImmediateAsTask let allowedToPost = allowedToPost - >> Async.StartAsTask + >> Async.StartImmediateAsTask [] let mapTests = diff --git a/tests/FsToolkit.ErrorHandling.TaskResult.Tests/TaskResultOption.fs b/tests/FsToolkit.ErrorHandling.TaskResult.Tests/TaskResultOption.fs index 5d3f5aba..e2240f77 100644 --- a/tests/FsToolkit.ErrorHandling.TaskResult.Tests/TaskResultOption.fs +++ b/tests/FsToolkit.ErrorHandling.TaskResult.Tests/TaskResultOption.fs @@ -10,11 +10,11 @@ open TestHelpers let getUserById x = getUserById x - |> Async.StartAsTask + |> Async.StartImmediateAsTask let getPostById x = getPostById x - |> Async.StartAsTask + |> Async.StartImmediateAsTask []