Skip to content

refactor: add drain() seam to threadHandler interface#2367

Open
nicolas-grekas wants to merge 1 commit intophp:mainfrom
nicolas-grekas:thread-handler-drain-seam
Open

refactor: add drain() seam to threadHandler interface#2367
nicolas-grekas wants to merge 1 commit intophp:mainfrom
nicolas-grekas:thread-handler-drain-seam

Conversation

@nicolas-grekas
Copy link
Copy Markdown
Contributor

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 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.

What

  • phpthread.go — interface gains drain().
  • threadregular.go / threadworker.go / threadinactive.go /
    threadtasks_test.go — empty drain() on each handler.
  • worker.godrainWorkerThreads calls thread.handler.drain()
    right before close(thread.drainChan).

Net change: +15 / -0.

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.
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.

1 participant