@@ -100,13 +100,14 @@ private function spawnParent(): void
100100 });
101101
102102 $ this ->parentStream ->watchRead (fn () => go (function () {
103- $ content = $ this ->parentStream ->read (1024 );
104- foreach ($ this ->zx7e ->fill ($ content ) as $ string ) {
105- $ this ->manager ->emitCommand (Command::fromString ($ string ), $ this ->worker ->name , $ this ->index );
106- }
103+ while ( $ content = $ this ->parentStream ->read (1024 )) {
104+ foreach ($ this ->zx7e ->fill ($ content ) as $ string ) {
105+ $ this ->manager ->emitCommand (Command::fromString ($ string ), $ this ->worker ->name , $ this ->index );
106+ }
107107
108- if ($ this ->parentStream ->eof ()) {
109- $ this ->parentStream ->close ();
108+ if ($ this ->parentStream ->eof ()) {
109+ $ this ->parentStream ->close ();
110+ }
110111 }
111112 }));
112113
@@ -140,7 +141,7 @@ public function reload(): void
140141 */
141142 public function terminate (): void
142143 {
143- Scheduler::terminate ($ this ->guard )->resolve ();
144+ Scheduler::terminate ($ this ->guard )->unwrap ();
144145
145146 try {
146147 $ this ->send (Command::make (BaseWorker::COMMAND_TERMINATE ));
@@ -206,33 +207,34 @@ private static function spawnChild(BaseWorker $worker, Stream $childStream): voi
206207
207208 $ childZx7e = new Zx7e ();
208209 $ childStream ->watchRead (static fn () => go (static function () use ($ worker , $ childStream , &$ childZx7e ) {
209- $ content = $ childStream ->read (1024 );
210- foreach ($ childZx7e ->fill ($ content ) as $ string ) {
211- $ command = Command::fromString ($ string );
212- switch ($ command ->name ) {
213- case BaseWorker::COMMAND_RELOAD :
214- $ worker ->onReload ();
215- break ;
216-
217- case BaseWorker::COMMAND_TERMINATE :
218- $ worker ->onTerminate ();
219- break ;
220-
221- case Manager::COMMAND_SUPERVISOR_METADATA :
222- $ id = $ command ->arguments ['id ' ];
223- if ($ owner = $ worker ->subs [$ id ] ?? null ) {
224- unset($ worker ->subs [$ id ]);
225- Scheduler::resume ($ owner , $ command ->arguments ['metadata ' ]);
226- }
227- break ;
228-
229- default :
230- $ worker ->onCommand ($ command );
210+ while ($ content = $ childStream ->read (1024 )) {
211+ foreach ($ childZx7e ->fill ($ content ) as $ string ) {
212+ $ command = Command::fromString ($ string );
213+ switch ($ command ->name ) {
214+ case BaseWorker::COMMAND_RELOAD :
215+ $ worker ->onReload ();
216+ break ;
217+
218+ case BaseWorker::COMMAND_TERMINATE :
219+ $ worker ->onTerminate ();
220+ break ;
221+
222+ case Manager::COMMAND_SUPERVISOR_METADATA :
223+ $ id = $ command ->arguments ['id ' ];
224+ if ($ owner = $ worker ->subs [$ id ] ?? null ) {
225+ unset($ worker ->subs [$ id ]);
226+ Scheduler::resume ($ owner , $ command ->arguments ['metadata ' ]);
227+ }
228+ break ;
229+
230+ default :
231+ $ worker ->onCommand ($ command );
232+ }
231233 }
232- }
233234
234- if ($ childStream ->eof ()) {
235- exit (0 );
235+ if ($ childStream ->eof ()) {
236+ exit (0 );
237+ }
236238 }
237239 }));
238240
0 commit comments