Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add BatcherCache, BatcherDictionary #390

Merged
merged 10 commits into from
Jun 6, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
ABG comments
  • Loading branch information
bartelink committed Jun 6, 2023
commit ecad52b5120a253be68b7327ae55f811c06dbe73
4 changes: 2 additions & 2 deletions src/Equinox.Core/AsyncBatchingGate.fs
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ type AsyncBatchingGate<'Req, 'Res>(dispatch: Func<'Req[], CancellationToken, Tas
// If current has not yet been dispatched, hop on and join
if current.TryAdd(req, dispatch, lingerMs, ct) then return! current.Await()
else // Any thread that discovers a batch in flight, needs to wait for it to conclude first
do! current.Await().ContinueWith<unit>(fun (_: Task) -> ()) // don't observe the exception or result from the in-flight batch
do! current.Await().ContinueWith<unit>(fun (_: Task) -> ()) // wait for, but don't observe the exception or result from the in-flight batch
// where competing threads discover a closed flight, we only want a single one to regenerate it
let _ = Interlocked.CompareExchange(&cell, AsyncBatch(), current)
return! x.ExecuteAsync(req, ct) }
return! x.ExecuteAsync(req, ct) } // but everyone attempts to merge their requests into the batch during the linger period

/// Include an item in the batch; await the collective dispatch (subject to the configured linger time)
member x.Execute(req) = async {
Expand Down