refactor: add drain() seam to threadHandler interface#2367
Open
nicolas-grekas wants to merge 1 commit intophp:mainfrom
Open
refactor: add drain() seam to threadHandler interface#2367nicolas-grekas wants to merge 1 commit intophp:mainfrom
nicolas-grekas wants to merge 1 commit intophp:mainfrom
Conversation
Third step of the split suggested in php#2287: land the handler-interface extension point that later handler types (background workers) need, without introducing any new behaviour. Each handler gains a drain() method, called by drainWorkerThreads right before drainChan is closed. All current implementations (regularThread, workerThread, inactiveThread, taskThread) are no-ops, so observable behaviour is unchanged. A later handler that needs to wake up a thread parked in a blocking C call (e.g. by closing a stop pipe) plugs its signal in here without modifying drainWorkerThreads again. - phpthread.go: interface gains drain(). - threadregular.go / threadworker.go / threadinactive.go / threadtasks_test.go: empty drain() on each handler. - worker.go: drainWorkerThreads calls thread.handler.drain() right before close(thread.drainChan). Full test suite and caddy module tests pass under -race.
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.
Third step of the split suggested in #2287: land the handler-interface
extension point that later handler types (background workers) need,
without introducing any new behaviour.
Each handler gains a
drain()method, called bydrainWorkerThreadsright before
drainChanis closed. All current implementations(
regularThread,workerThread,inactiveThread,taskThread) areno-ops, so observable behaviour is unchanged. A later handler that
needs to wake up a thread parked in a blocking C call (e.g. by closing
a stop pipe) plugs its signal in here without modifying
drainWorkerThreadsagain.What
phpthread.go— interface gainsdrain().threadregular.go/threadworker.go/threadinactive.go/threadtasks_test.go— emptydrain()on each handler.worker.go—drainWorkerThreadscallsthread.handler.drain()right before
close(thread.drainChan).Net change: +15 / -0.