Skip to content

Commit

Permalink
Fix merge sources (#41)
Browse files Browse the repository at this point in the history
* Fix Merge Sources

* Prove parallelism in tests

* testSequencedGroup MergeSources

* reduce CI test count fscheck

* Change check strategy
  • Loading branch information
TheAngryByrd authored Feb 7, 2024
1 parent 4f4c0e0 commit 5585ebc
Show file tree
Hide file tree
Showing 25 changed files with 1,422 additions and 147 deletions.
1 change: 1 addition & 0 deletions paket.dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ group Test
source https://www.nuget.org/api/v2
source https://api.nuget.org/v3/index.json
nuget Expecto >= 10.1.0
nuget Expecto.FsCheck
nuget Microsoft.Bcl.TimeProvider
nuget Microsoft.Bcl.AsyncInterfaces >= 8
nuget TimeProviderExtensions
Expand Down
5 changes: 5 additions & 0 deletions paket.lock
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,11 @@ NUGET
Expecto (10.1)
FSharp.Core (>= 7.0.200) - restriction: >= net6.0
Mono.Cecil (>= 0.11.4 < 1.0) - restriction: >= net6.0
Expecto.FsCheck (10.1)
Expecto (>= 10.1) - restriction: >= net6.0
FsCheck (>= 2.16.5 < 3.0) - restriction: >= net6.0
FsCheck (2.16.6) - restriction: >= net6.0
FSharp.Core (>= 4.2.3) - restriction: || (>= net452) (>= netstandard1.6)
FSharp.Control.TaskSeq (0.3)
FSharp.Core (>= 6.0.2) - restriction: >= netstandard2.1
FSharp.Core (7.0.401) - restriction: >= netstandard2.1
Expand Down
76 changes: 52 additions & 24 deletions src/IcedTasks/CancellablePoolingValueTask.fs
Original file line number Diff line number Diff line change
Expand Up @@ -146,62 +146,90 @@ module CancellablePoolingValueTasks =

/// Specify a Source of CancellationToken -> ValueTask<_> on the real type to allow type inference to work
member inline _.Source
(x: CancellationToken -> ValueTask<_>)
([<InlineIfLambda>] x: CancellationToken -> ValueTask<_>)
: CancellationToken -> Awaiter<ValueTaskAwaiter<_>, _> =
fun ct ->
(x ct)
|> Awaitable.GetAwaiter

[<NoEagerConstraintApplication>]
member inline this.MergeSources
(
[<InlineIfLambda>] left: CancellationToken -> 'Awaiter1,
[<InlineIfLambda>] right: CancellationToken -> 'Awaiter2
) =
this.Run(
this.Bind(
left,
fun leftR -> this.BindReturn(right, (fun rightR -> struct (leftR, rightR)))
this.Source(
this.Run(
this.Bind(
(fun ct -> this.Source(ValueTask<_> ct)),
fun ct ->
let left = left ct
let right = right ct

(this.Bind(
left,
fun leftR ->
this.BindReturn(right, (fun rightR -> struct (leftR, rightR)))
))
)
)
)
>> Awaitable.GetAwaiter


[<NoEagerConstraintApplication>]
member inline this.MergeSources
(
left: 'Awaiter1,
[<InlineIfLambda>] right: CancellationToken -> 'Awaiter2
) =
this.Run(
this.Bind(
left,
fun leftR -> this.BindReturn(right, (fun rightR -> struct (leftR, rightR)))
this.Source(
this.Run(
this.Bind(
(fun ct -> this.Source(ValueTask<_> ct)),
fun ct ->
let right = right ct

(this.Bind(
left,
fun leftR ->
this.BindReturn(right, (fun rightR -> struct (leftR, rightR)))
))
)
)
)
>> Awaitable.GetAwaiter


[<NoEagerConstraintApplication>]
member inline this.MergeSources
(
[<InlineIfLambda>] left: CancellationToken -> 'Awaiter1,
right: 'Awaiter2
) =
this.Run(
this.Bind(
left,
fun leftR -> this.BindReturn(right, (fun rightR -> struct (leftR, rightR)))

this.Source(
this.Run(
this.Bind(
(fun ct -> this.Source(ValueTask<_> ct)),
fun ct ->
let left = left ct

(this.Bind(
left,
fun leftR ->
this.BindReturn(right, (fun rightR -> struct (leftR, rightR)))
))
)
)
)
>> Awaitable.GetAwaiter


[<NoEagerConstraintApplication>]
member inline this.MergeSources(left: 'Awaiter1, right: 'Awaiter2) =
this.Run(
this.Bind(
left,
fun leftR -> this.BindReturn(right, (fun rightR -> struct (leftR, rightR)))
this.Source(
this.Run(
this.Bind(
left,
fun leftR -> this.BindReturn(right, (fun rightR -> struct (leftR, rightR)))
)
)
)
>> Awaitable.GetAwaiter


/// Contains the cancellableTask computation expression builder.
Expand Down
76 changes: 52 additions & 24 deletions src/IcedTasks/CancellableTask.fs
Original file line number Diff line number Diff line change
Expand Up @@ -143,60 +143,88 @@ module CancellableTasks =

/// Specify a Source of CancellationToken -> Task<_> on the real type to allow type inference to work
member inline _.Source
(x: CancellationToken -> Task<_>)
([<InlineIfLambda>] x: CancellationToken -> Task<_>)
: CancellationToken -> Awaiter<TaskAwaiter<_>, _> =
fun ct -> Awaitable.GetTaskAwaiter(x ct)

[<NoEagerConstraintApplication>]
member inline this.MergeSources
(
[<InlineIfLambda>] left: CancellationToken -> 'Awaiter1,
[<InlineIfLambda>] right: CancellationToken -> 'Awaiter2
) =
this.Run(
this.Bind(
left,
fun leftR -> this.BindReturn(right, (fun rightR -> struct (leftR, rightR)))
this.Source(
this.Run(
this.Bind(
(fun ct -> this.Source(ValueTask<_> ct)),
fun ct ->
let left = left ct
let right = right ct

(this.Bind(
left,
fun leftR ->
this.BindReturn(right, (fun rightR -> struct (leftR, rightR)))
))
)
)
)
>> Awaitable.GetTaskAwaiter


[<NoEagerConstraintApplication>]
member inline this.MergeSources
(
left: 'Awaiter1,
[<InlineIfLambda>] right: CancellationToken -> 'Awaiter2
) =
this.Run(
this.Bind(
left,
fun leftR -> this.BindReturn(right, (fun rightR -> struct (leftR, rightR)))
this.Source(
this.Run(
this.Bind(
(fun ct -> this.Source(ValueTask<_> ct)),
fun ct ->
let right = right ct

(this.Bind(
left,
fun leftR ->
this.BindReturn(right, (fun rightR -> struct (leftR, rightR)))
))
)
)
)
>> Awaitable.GetTaskAwaiter


[<NoEagerConstraintApplication>]
member inline this.MergeSources
(
[<InlineIfLambda>] left: CancellationToken -> 'Awaiter1,
right: 'Awaiter2
) =
this.Run(
this.Bind(
left,
fun leftR -> this.BindReturn(right, (fun rightR -> struct (leftR, rightR)))

this.Source(
this.Run(
this.Bind(
(fun ct -> this.Source(ValueTask<_> ct)),
fun ct ->
let left = left ct

(this.Bind(
left,
fun leftR ->
this.BindReturn(right, (fun rightR -> struct (leftR, rightR)))
))
)
)
)
>> Awaitable.GetTaskAwaiter


[<NoEagerConstraintApplication>]
member inline this.MergeSources(left: 'Awaiter1, right: 'Awaiter2) =
this.Run(
this.Bind(
left,
fun leftR -> this.BindReturn(right, (fun rightR -> struct (leftR, rightR)))
this.Source(
this.Run(
this.Bind(
left,
fun leftR -> this.BindReturn(right, (fun rightR -> struct (leftR, rightR)))
)
)
)
>> Awaitable.GetTaskAwaiter


/// Contains methods to build CancellableTasks using the F# computation expression syntax
Expand Down
76 changes: 52 additions & 24 deletions src/IcedTasks/CancellableValueTask.fs
Original file line number Diff line number Diff line change
Expand Up @@ -143,62 +143,90 @@ module CancellableValueTasks =

/// Specify a Source of CancellationToken -> ValueTask<_> on the real type to allow type inference to work
member inline _.Source
(x: CancellationToken -> ValueTask<_>)
([<InlineIfLambda>] x: CancellationToken -> ValueTask<_>)
: CancellationToken -> Awaiter<ValueTaskAwaiter<_>, _> =
fun ct ->
(x ct)
|> Awaitable.GetAwaiter

[<NoEagerConstraintApplication>]
member inline this.MergeSources
(
[<InlineIfLambda>] left: CancellationToken -> 'Awaiter1,
[<InlineIfLambda>] right: CancellationToken -> 'Awaiter2
) =
this.Run(
this.Bind(
left,
fun leftR -> this.BindReturn(right, (fun rightR -> struct (leftR, rightR)))
this.Source(
this.Run(
this.Bind(
(fun ct -> this.Source(ValueTask<_> ct)),
fun ct ->
let left = left ct
let right = right ct

(this.Bind(
left,
fun leftR ->
this.BindReturn(right, (fun rightR -> struct (leftR, rightR)))
))
)
)
)
>> Awaitable.GetAwaiter


[<NoEagerConstraintApplication>]
member inline this.MergeSources
(
left: 'Awaiter1,
[<InlineIfLambda>] right: CancellationToken -> 'Awaiter2
) =
this.Run(
this.Bind(
left,
fun leftR -> this.BindReturn(right, (fun rightR -> struct (leftR, rightR)))
this.Source(
this.Run(
this.Bind(
(fun ct -> this.Source(ValueTask<_> ct)),
fun ct ->
let right = right ct

(this.Bind(
left,
fun leftR ->
this.BindReturn(right, (fun rightR -> struct (leftR, rightR)))
))
)
)
)
>> Awaitable.GetAwaiter


[<NoEagerConstraintApplication>]
member inline this.MergeSources
(
[<InlineIfLambda>] left: CancellationToken -> 'Awaiter1,
right: 'Awaiter2
) =
this.Run(
this.Bind(
left,
fun leftR -> this.BindReturn(right, (fun rightR -> struct (leftR, rightR)))

this.Source(
this.Run(
this.Bind(
(fun ct -> this.Source(ValueTask<_> ct)),
fun ct ->
let left = left ct

(this.Bind(
left,
fun leftR ->
this.BindReturn(right, (fun rightR -> struct (leftR, rightR)))
))
)
)
)
>> Awaitable.GetAwaiter


[<NoEagerConstraintApplication>]
member inline this.MergeSources(left: 'Awaiter1, right: 'Awaiter2) =
this.Run(
this.Bind(
left,
fun leftR -> this.BindReturn(right, (fun rightR -> struct (leftR, rightR)))
this.Source(
this.Run(
this.Bind(
left,
fun leftR -> this.BindReturn(right, (fun rightR -> struct (leftR, rightR)))
)
)
)
>> Awaitable.GetAwaiter


/// Contains the cancellableTask computation expression builder.
Expand Down
12 changes: 7 additions & 5 deletions src/IcedTasks/PoolingValueTask.fs
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,16 @@ module PoolingValueTasks =
/// Specify a Source of ValueTask<_> on the real type to allow type inference to work
member inline _.Source(v: ValueTask<_>) = Awaitable.GetAwaiter v

[<NoEagerConstraintApplication>]
member inline this.MergeSources(left, right) =
this.Run(
this.Bind(
left,
fun leftR -> this.BindReturn(right, (fun rightR -> struct (leftR, rightR)))
this.Source(
this.Run(
this.Bind(
left,
fun leftR -> this.BindReturn(right, (fun rightR -> struct (leftR, rightR)))
)
)
)
|> Awaitable.GetAwaiter


/// Contains the poolingValueTask computation expression builder.
Expand Down
Loading

0 comments on commit 5585ebc

Please sign in to comment.