forked from hschimpf/parallel-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Task management for removing & stopping tasks
- FIX: Missing implementation of Runner::stopRunningTasks() hschimpf#10 - Added Scheduler::removePendingTasks() - Renamed Scheduler::removeTasks() to removeAllTasks() - Added tests for removePendingTasks() and removeAllTasks()
- Loading branch information
Showing
8 changed files
with
194 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
src/Internals/Commands/Runner/RemovePendingTasksMessage.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace HDSSolutions\Console\Parallel\Internals\Commands\Runner; | ||
|
||
use HDSSolutions\Console\Parallel\Internals\Commands\ParallelCommandMessage; | ||
use HDSSolutions\Console\Parallel\Internals\Runner; | ||
|
||
/** | ||
* Message sent to {@see Runner} to execute {@see Runner::removePendingTasks()} action | ||
*/ | ||
final class RemovePendingTasksMessage extends ParallelCommandMessage { | ||
|
||
public function __construct() { | ||
parent::__construct('remove_pending_tasks'); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace HDSSolutions\Console\Parallel\Internals\Commands\Runner; | ||
|
||
use HDSSolutions\Console\Parallel\Internals\Commands\ParallelCommandMessage; | ||
use HDSSolutions\Console\Parallel\Internals\Runner; | ||
|
||
/** | ||
* Message sent to {@see Runner} to execute {@see Runner::stopRunningTasks()} action | ||
*/ | ||
final class StopRunningTasksMessage extends ParallelCommandMessage { | ||
|
||
public function __construct() { | ||
parent::__construct('stop_running_tasks', [ true ]); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace HDSSolutions\Console\Tests\Workers; | ||
|
||
use HDSSolutions\Console\Parallel\ParallelWorker; | ||
|
||
final class LongRunningWorker extends ParallelWorker { | ||
|
||
protected function process(int $goal = 0): int { | ||
$waited = 0; | ||
do { | ||
usleep(100_000); | ||
$waited += 100; | ||
} while ($waited <= $goal); | ||
|
||
return $goal; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters