Timer::add in master process is impossible ? I think it can be
- Dominant language
- PHP
- Stars
- 11.6k
- Forks
- 2.2k
- Avg merge
- 11h 30m
- Merged PRs (30d)
- 3
Description
At some situation i need add Timer at master process, but it look like imposible because master have `monitorWorkersForLinux` method with `pcntl_wait` function what will be block master process until worker will not shutdown or master will get somу signal. While it was blocking no one Event library can't run timer...but...
Some Event library has own `pcntl_wait` analogs , like `Swoole\Coroutine\System::wait` in Swoole (https://wiki.swoole.com/#/coroutine/system?id=wait). It will do same things as `pcntl_wait` but additional Timer can be work in master process
Is it possible change `monitorWorkersForLinux` ` $pid = \pcntl_wait($status, \WUNTRACED);`->`static::$globalEvent->wait()` ? And EventInterface need be abstract with share method `wait` by default have `pcntl_wait` (except Swoole) and return array `['pid'=>$pid, 'signal'=>$status]` (like a `Swoole\Coroutine\System::wait` return array's format) or stay like Interface but need have abstract method `wait():array` (but in this realisation each Event need `wait` method with `pcntl_wait` except Swoole)
Because not it impossible change `monitorWorkersForLinux` by extends class , because it have private property , additionaly this method have a lot of code, but only need change one line of code
@walkor
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reading monitorWorkersForLinux and EventInterface, focusing on the pcntl_wait call and how the master process runs timers. Determine whether the event abstraction can preserve worker monitoring while allowing master-process timers, then validate the chosen interface and behavior with the relevant existing event implementations and tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100