From d676a59753c8fc4980d861de84fe994faba3f0e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Schr=C3=B6er?= Date: Sat, 3 Aug 2024 15:17:34 +0200 Subject: [PATCH] allow to trigger the unblock and signal processing externally --- CHANGELOG.md | 9 +++++++++ src/ProcessManager.php | 11 +++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4bea3be..ed50774 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # Changelog +## Release [v7.1.0](https://github.com/sweikenb/pcntl/releases/tag/v7.1.0) + +**Features** + +- Introduced the `unblock()`-function to the `ProcessManager` so the process-unblock and signal dispatching can be + triggered externally too + +* * * + ## Release [v7.0.0](https://github.com/sweikenb/pcntl/releases/tag/v7.0.0) **Bugfixes** diff --git a/src/ProcessManager.php b/src/ProcessManager.php index ce94131..4fe626d 100644 --- a/src/ProcessManager.php +++ b/src/ProcessManager.php @@ -200,11 +200,18 @@ public function wait(?callable $callback = null): void } } } - usleep(5000); - pcntl_signal_dispatch(); + + // unblock the system and dispatch queued signals + $this->unblock(); } } + public function unblock(): void + { + usleep(mt_rand(50, 500)); + pcntl_signal_dispatch(); + } + public function onThreadCreate(callable $callback): self { $this->onThreadCreated[] = $callback;