Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
46e1a24
Implement worker console message output alongside ProgressBar
devin-ai-integration[bot] Jul 23, 2026
def3d9a
docs: add console message example output
devin-ai-integration[bot] Jul 23, 2026
faf3bcc
tests: bootstrap parallel extension in spawned test scripts
devin-ai-integration[bot] Jul 23, 2026
71fb6c5
fix: init console worker from Runner thread, not from task thread
devin-ai-integration[bot] Jul 23, 2026
7b2cf17
fix: use dedicated Runtime for ConsoleWorker and reset state on stop
devin-ai-integration[bot] Jul 23, 2026
51d95a8
fix: drop ConsoleWorker thread, write non-progress messages directly …
devin-ai-integration[bot] Jul 23, 2026
f3f8dcd
test: disable opcache JIT before parallel tests to avoid thread races
devin-ai-integration[bot] Jul 23, 2026
19caddc
test: disable opcache JIT via phpunit.xml to avoid parallel thread races
devin-ai-integration[bot] Jul 23, 2026
2a307fa
Revert phpunit.xml JIT override (cannot change opcache.jit at runtime)
devin-ai-integration[bot] Jul 23, 2026
fc892b9
fix: route worker console messages through dedicated ConsoleWorker an…
devin-ai-integration[bot] Jul 23, 2026
f3c1d98
fix: route all console messages through ProgressBarWorker, drop Conso…
devin-ai-integration[bot] Jul 23, 2026
bb4e7a7
fix: only connect ProgressBar worker when progress is enabled
devin-ai-integration[bot] Jul 23, 2026
039a745
fix: always connect ProgressBar worker for console message routing
devin-ai-integration[bot] Jul 23, 2026
d87c4a4
refactor: keep ProgressBar/output inside Runner thread instead of Pro…
devin-ai-integration[bot] Jul 23, 2026
4ed5532
test: add timestamps to test lifecycle for CI debugging
devin-ai-integration[bot] Jul 23, 2026
0b85c33
fix: make Writer worker autoloadable and add test timing/debug helpers
devin-ai-integration[bot] Jul 24, 2026
5078d92
test: relax progressbar message assertion due to parallel ordering
devin-ai-integration[bot] Jul 24, 2026
bbb7db9
docs: update CHANGELOG for console messages and Runner-owned ProgressBar
devin-ai-integration[bot] Jul 24, 2026
265a44e
docs: update RFC status and implementation note
devin-ai-integration[bot] Jul 24, 2026
2bc8792
refactor: address review comments
devin-ai-integration[bot] Jul 24, 2026
6ec4243
fix: restore getRunnerChannel() for RegisteredWorker progress enablement
devin-ai-integration[bot] Jul 24, 2026
032315f
docs: update ManagesTasks comments to reflect Runner-owned output han…
devin-ai-integration[bot] Jul 24, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
with:
php-version: ${{ inputs.php }}
extensions: ${{ env.extensions }}
ini-values: opcache.enable_cli=1, opcache.jit=tracing, opcache.jit_buffer_size=64M
ini-values: opcache.enable_cli=1, opcache.jit=off
coverage: none

- name: Install dependencies
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

All notable changes to **parallel-sdk** are documented in this file. The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and the project adheres to [Semantic Versioning](https://semver.org/).

## Unreleased

### Added
- `ParallelWorker::write()` and `ParallelWorker::writeln()` methods to emit console messages from workers without them being overwritten by the ProgressBar.
- `WriteOutputMessage` command to route `write()`/`writeln()` calls to the `Runner` coordinator.

### Changed
- ProgressBar and console-message handling is now owned directly by the `Runner` thread on a `stderr` `OutputInterface`, so `clear()`/`write()`/`display()` work correctly together without extra coordinator threads.

## `3.0.0` – 2025-07-04

### Added
Expand Down
41 changes: 41 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,8 @@ Available methods are:
- `setProgress(int $step)`
- `display()`
- `clear()`
- `write(string $message, bool $newline = false)`
- `writeln(string $message)`

```php
use HDSSolutions\Console\Parallel\ParallelWorker;
Expand All @@ -332,6 +334,7 @@ final class ExampleWorker extends ParallelWorker {
$microseconds = random_int(100, 500);
$this->setMessage(sprintf("ExampleWorker >> Hello from task #%u, I'll wait %sms", $number, $microseconds));
usleep($microseconds * 1000);
$this->writeln(sprintf("ExampleWorker >> Finished task #%u", $number));
$this->advance();
// end example process

Expand All @@ -349,6 +352,44 @@ final class ExampleWorker extends ParallelWorker {
memory: 562 KiB, threads: 12x ~474 KiB, Σ 5,6 MiB ↑ 5,6 MiB
```

#### Console messages

Use `write()` or `writeln()` to emit ad-hoc console messages from a worker. When a ProgressBar is active, the bar is temporarily hidden, the message is printed, and the bar is redrawn below it so the message is not overwritten.

These methods also work for workers that did not enable `withProgress()`; messages are then written directly to the console.

```php
use HDSSolutions\Console\Parallel\ParallelWorker;

final class ExampleWorker extends ParallelWorker {

protected function process(int $number = 0): int {
$this->writeln(sprintf("Processing task #%u", $number));

// ... do work ...

$this->writeln(sprintf("Finished task #%u", $number));

return $number;
}

}
```

#### Example output
When used together with `withProgress()`, messages are printed between progress-bar redraws instead of being overwritten:

```bash
0 of 10: Starting...
[>------------------------------------------------------------------------] 0%
elapsed: < 1 sec, remaining: < 1 sec, ?? items/s,memory: ??
Processing task #5
Finished task #5
1 of 10: Task #5
[=====>-------------------------------------------------------------------] 10%
elapsed: < 1 sec, remaining: < 1 sec, ~1.00 items/s,memory: ??
```

### References
1. [parallel\bootstrap()](https://www.php.net/manual/en/parallel.bootstrap.php)
2. [parallel\Runtime](https://www.php.net/manual/en/class.parallel-runtime.php)
Expand Down
Loading
Loading