Skip to content

Commit f31dc24

Browse files
committed
Update package versions and add BenchmarkDotNet reference; refactor awaiter handling in CancellableTask modules
1 parent e4439e6 commit f31dc24

File tree

6 files changed

+29
-24
lines changed

6 files changed

+29
-24
lines changed

Directory.Packages.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<PackageVersion Include="Hopac" Version="0.5.1" />
1010
<PackageVersion Include="FSharp.Control.AsyncSeq" Version="3.2.1" />
1111
<PackageVersion Include="Fable.Core" Version="4.2.0" />
12-
<PackageVersion Include="IcedTasks" Version="0.11.7" />
12+
<PackageVersion Include="IcedTasks" Version="0.11.8" />
1313
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="1.1.1" />
1414
<PackageVersion Include="Microsoft.Bcl.AsyncInterfaces" Version="6.0.0" />
1515

benchmarks/SeqTests.fs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ open BenchmarkDotNet.Mathematics
66
open BenchmarkDotNet.Configs
77
open System.Threading
88
open System
9+
open FsToolkit.ErrorHandling
910

1011
module sequenceResultMTests =
1112

benchmarks/benchmarks.fsproj

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project Sdk="Microsoft.NET.Sdk">
33
<PropertyGroup>
4-
<TargetFramework>net8.0</TargetFramework>
4+
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
55
<OutputType>Exe</OutputType>
66
</PropertyGroup>
77
<PropertyGroup>
@@ -27,5 +27,8 @@
2727
<ProjectReference
2828
Include="..\src\FsToolkit.ErrorHandling.JobResult\FsToolkit.ErrorHandling.JobResult.fsproj" />
2929
</ItemGroup>
30-
<Import Project="..\.paket\Paket.Restore.targets" />
30+
31+
<ItemGroup>
32+
<PackageReference Include="BenchmarkDotnet"/>
33+
</ItemGroup>
3134
</Project>

src/FsToolkit.ErrorHandling.IcedTasks/CancellableTaskResultBuilderBase.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,9 +1057,9 @@ module CancellableTaskResultBuilderBase =
10571057
///
10581058
member inline _.Using
10591059
(
1060-
resource: #IDisposable,
1060+
resource: #IDisposableNull,
10611061
binder:
1062-
#IDisposable
1062+
#IDisposableNull
10631063
-> CancellableTaskResultBuilderBaseCode<'TOverall, 'T, 'Error, 'Builder>
10641064
) =
10651065
ResumableCode.Using(resource, binder)

src/FsToolkit.ErrorHandling.IcedTasks/CancellableTaskResultCE.fs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,16 @@ module CancellableTaskResultCE =
5353
if step then
5454
MethodBuilder.SetResult(&sm.Data.MethodBuilder, sm.Data.Result)
5555
else
56-
let mutable awaiter =
57-
sm.ResumptionDynamicInfo.ResumptionData
58-
:?> ICriticalNotifyCompletion
59-
60-
MethodBuilder.AwaitUnsafeOnCompleted(
61-
&sm.Data.MethodBuilder,
62-
&awaiter,
63-
&sm
64-
)
65-
56+
match sm.ResumptionDynamicInfo.ResumptionData with
57+
| :? ICriticalNotifyCompletion as awaiter ->
58+
let mutable awaiter = awaiter
59+
60+
MethodBuilder.AwaitUnsafeOnCompleted(
61+
&sm.Data.MethodBuilder,
62+
&awaiter,
63+
&sm
64+
)
65+
| awaiter -> assert not (isNull awaiter)
6666
with exn ->
6767
savedExn <- exn
6868
// Run SetException outside the stack unwind, see https://github.com/dotnet/roslyn/issues/26567

src/FsToolkit.ErrorHandling.IcedTasks/CancellableTaskValidationCE.fs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -107,15 +107,16 @@ module CancellableTaskValidationCE =
107107
// sm.Data.MethodBuilder.SetResult sm.Data.Result
108108
MethodBuilder.SetResult(&sm.Data.MethodBuilder, sm.Data.Result)
109109
else
110-
let mutable awaiter =
111-
sm.ResumptionDynamicInfo.ResumptionData
112-
:?> ICriticalNotifyCompletion
113-
114-
MethodBuilder.AwaitUnsafeOnCompleted(
115-
&sm.Data.MethodBuilder,
116-
&awaiter,
117-
&sm
118-
)
110+
match sm.ResumptionDynamicInfo.ResumptionData with
111+
| :? ICriticalNotifyCompletion as awaiter ->
112+
let mutable awaiter = awaiter
113+
114+
MethodBuilder.AwaitUnsafeOnCompleted(
115+
&sm.Data.MethodBuilder,
116+
&awaiter,
117+
&sm
118+
)
119+
| awaiter -> assert not (isNull awaiter)
119120

120121
with exn ->
121122
savedExn <- exn

0 commit comments

Comments
 (0)