Skip to content

Commit

Permalink
allow to trigger the unblock and signal processing externally
Browse files Browse the repository at this point in the history
  • Loading branch information
sweikenb committed Aug 3, 2024
1 parent ad3b9e2 commit d676a59
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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**
Expand Down
11 changes: 9 additions & 2 deletions src/ProcessManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit d676a59

Please sign in to comment.