Rename DefaultWorker to ContextWorker and make it internal

This commit is contained in:
Niklas Keller 2023-02-14 21:29:34 +01:00
parent 0a86594cf3
commit f8bad14018
No known key found for this signature in database
GPG Key ID: AFA536ABA90C76A6
3 changed files with 13 additions and 7 deletions

View File

@ -99,9 +99,7 @@ class FetchTask implements Task
```
```php
use Amp\Parallel\Worker\DefaultWorker;
$worker = new DefaultWorker();
$worker = Amp\Parallel\Worker\createWorker();
$task = new FetchTask('https://amphp.org');
$execution = $worker->submit($task);

View File

@ -6,6 +6,7 @@ use Amp\Cancellation;
use Amp\ForbidCloning;
use Amp\ForbidSerialization;
use Amp\Parallel\Context\ContextFactory;
use Amp\Parallel\Worker\Internal\ContextWorker;
use function Amp\Parallel\Context\contextFactory;
/**
@ -39,6 +40,6 @@ final class DefaultWorkerFactory implements WorkerFactory
$script[] = $this->bootstrapPath;
}
return new DefaultWorker(($this->contextFactory ?? contextFactory())->start($script, $cancellation));
return new ContextWorker(($this->contextFactory ?? contextFactory())->start($script, $cancellation));
}
}

View File

@ -1,6 +1,6 @@
<?php declare(strict_types=1);
namespace Amp\Parallel\Worker;
namespace Amp\Parallel\Worker\Internal;
use Amp\Cancellation;
use Amp\CancelledException;
@ -10,6 +10,11 @@ use Amp\ForbidSerialization;
use Amp\Future;
use Amp\Parallel\Context\Context;
use Amp\Parallel\Context\StatusError;
use Amp\Parallel\Worker\Execution;
use Amp\Parallel\Worker\Internal;
use Amp\Parallel\Worker\Task;
use Amp\Parallel\Worker\Worker;
use Amp\Parallel\Worker\WorkerException;
use Amp\Pipeline\Queue;
use Amp\Sync\ChannelException;
use Amp\TimeoutCancellation;
@ -17,9 +22,11 @@ use Revolt\EventLoop;
use function Amp\async;
/**
* Default worker implementation executing {@see Task}s.
* Context based worker implementation executing {@see Task}s.
*
* @internal
*/
final class DefaultWorker implements Worker
final class ContextWorker implements Worker
{
use ForbidCloning;
use ForbidSerialization;