Skip to content

Commit

Permalink
Merge pull request #17 from hschimpf/2.x-dev
Browse files Browse the repository at this point in the history
Minor fixes
  • Loading branch information
hschimpf authored Apr 18, 2023
2 parents d3a7720 + a30430e commit db652cc
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/Internals/ProgressBarWorker/HasChannels.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ protected function send(mixed $value): mixed {
}

protected function release(): void {
if ( !PARALLEL_EXT_LOADED) return;

$this->progressbar_channel->release();
}

Expand Down
3 changes: 3 additions & 0 deletions src/Internals/Worker/CommunicatesWithProgressBarWorker.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ final public function clear(): void {
}

private function newProgressBarAction(string $action, ...$args): void {
// check if progressbar is active
if ($this->progressbar_channel === null) return;

$message = new Commands\ProgressBar\ProgressBarActionMessage(
action: $action,
args: $args,
Expand Down
2 changes: 1 addition & 1 deletion src/ParallelWorker.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ abstract class ParallelWorker implements Contracts\ParallelWorker {
/**
* @var mixed Worker execution result
*/
private mixed $result;
private mixed $result = null;

final public function getState(): int {
return $this->state;
Expand Down
3 changes: 3 additions & 0 deletions tests/ParallelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ public function testProgressBar(): void {
}
}

/** @depends testThatParallelExtensionIsAvailable */
public function testThatTasksCanBeRemovedFromQueue(): void {
Scheduler::using(Workers\LongRunningWorker::class);

Expand Down Expand Up @@ -155,6 +156,7 @@ public function testThatTasksCanBeRemovedFromQueue(): void {
Scheduler::removeAllTasks();
}

/** @depends testThatParallelExtensionIsAvailable */
public function testThatTasksCanBeCancelled(): void {
Scheduler::using(Workers\LongRunningWorker::class);

Expand Down Expand Up @@ -185,6 +187,7 @@ public function testThatTasksCanBeCancelled(): void {
Scheduler::removeAllTasks();
}

/** @depends testThatParallelExtensionIsAvailable */
public function testThatChannelsDontOverlap(): void {
Scheduler::using(Workers\WorkerWithSubWorkers::class);

Expand Down

0 comments on commit db652cc

Please sign in to comment.