Sync main with master#280
Merged
Merged
Conversation
The worker service runs each dispatch's routine on a loop taken from a ResourcePool keyed by the constant "worker". The pool used ttl=0, so the loop's reference count fell to zero at the end of every dispatch and the finalizer tore the loop and its daemon thread down, only for the next dispatch to build them again. That per-dispatch churn, and the task drain the teardown runs, dominate dispatch latency and are implicated in a cross-loop lock error under concurrency. Give the pool a positive time-to-live, _WORKER_LOOP_TTL, so one warm loop and thread serve dispatches within the window and are torn down only once the loop sits idle past the TTL. An explicit stop still clears the pool at once, so no loop or thread outlives the service.
Assert one warm worker loop and daemon thread serve two sequential dispatches, that stopping the service reaps the warm thread with no factory-displacement warning, and that an idle loop is reaped once its time-to-live elapses. Add an autouse teardown that reaps any loop a test leaves warm, draining residual tasks across successive generations as the production finalizer does, so a cancelled task's follow-up cleanup is not stranded.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Auto-generated by the sync branches workflow.