Skip to content

Add atomic synchronous TrySubmit for bounded admission - #38

Merged
dombrovsky merged 10 commits into
mainfrom
issue-37-synchronous-try-submit
Oct 25, 2026
Merged

dombrovsky merged 10 commits into
mainfrom
issue-37-synchronous-try-submit

Conversation

@dombrovsky

@dombrovsky dombrovsky commented Oct 16, 2026 •

Copy link
Copy Markdown
Owner

Synchronous event producers need to reserve capacity before deciding whether to accept an event or consume a cooldown. BoundedAdmissionController.TrySubmit returns an immediate Accepted / Full / Closed decision and a completion task on acceptance.

Closes #37.

API and behavior

  • 12 overloads: keyed/unkeyed typed-state ValueTask cores and common Task conveniences, with optional cancellation and result support.
  • Reuses existing queues and atomic global/per-key accounting. Preserves FIFO, eligible-waiter priority, round-robin scheduling, concurrency limits, cancellation, and lifetime ownership.
  • One guarded drain dispatches accepted work off the producer's stack, including middleware and custom terminal scheduling callbacks. No capacity waits or admission waiters.
  • Keeps Enqueue, Submit(Wait), and Submit(Reject). The latter supports enqueue middleware that cannot guarantee a synchronous decision. ITaskScheduler and terminal schedulers are unchanged.

Supported pipelines

Native pipelines support bounded/coordinated policies, annotations, and execution/completion middleware. Other enqueue middleware, opaque terminals, and multiple uncoordinated budgets fail before work creation or reservation.

Existing thread-affine context semantics remain. Immediate legacy submissions avoid unnecessary context capture; deferred work captures context so mixed producers can share the drain safely.

Documentation and validation

Usage guides contain API comparisons, examples, and compatibility rules; drain invariants live in the existing design notes. The temporary dispatch benchmark/profiling project is removed. Its harness and investigation remain available in commit history. Production dispatch regression tests remain.

  • Release builds, analyzers, API baselines, formatting, and NativeAOT checks passed.
  • Full implementation suite: 5,024/5,024 on .NET 8/10; C# 10/12 consumer checks passed.
  • Documentation cleanup: examples compiled and ran on .NET 8/10, links/anchors checked, and 66/66 dispatch regression tests passed.

@dombrovsky
dombrovsky force-pushed the issue-37-synchronous-try-submit branch from bfb83cb to 27f2b5c Compare October 24, 2026 21:14
@dombrovsky
dombrovsky merged commit 826f95a into main Oct 25, 2026
10 checks passed
@dombrovsky
dombrovsky deleted the issue-37-synchronous-try-submit branch October 25, 2026 23:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support atomic synchronous TrySubmit for bounded admission

1 participant