Skip to content

Commit

Permalink
Added Scheduler::removeTask() method to the README docs
Browse files Browse the repository at this point in the history
  • Loading branch information
hschimpf committed Apr 1, 2024
1 parent 11439ce commit 793cbe5
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,23 @@ foreach (Scheduler::getTasks() as $task) {
}
```

### Stop all processing immediately
### Remove a pending/running task
You can remove a specific task from the processing queue if you need to.
```php
use HDSSolutions\Console\Parallel\Scheduler;
use HDSSolutions\Console\Parallel\Task;

foreach (Scheduler::getTasks() as $task) {
// if for some reason you want to remove a task, or just want to free memory when a task finishes
if (someValidation($task) || $task->wasProcessed()) {
// this will remove the task from the processing queue
// IMPORTANT: if the task is already running, it will be stopped
Scheduler::removeTask($task);
}
}
```

### Stop processing all tasks immediately
If you need to stop all right away, you can call the `Scheduler::stop()` method. This will stop processing all tasks immediately.
```php
use HDSSolutions\Console\Parallel\Scheduler;
Expand Down

0 comments on commit 793cbe5

Please sign in to comment.