Skip to content

Commit

Permalink
Bit of cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
trowski committed Feb 8, 2022
1 parent 062fadc commit d491b02
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 16 deletions.
4 changes: 1 addition & 3 deletions src/Worker/DefaultWorkerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ final class DefaultWorkerFactory implements WorkerFactory
{
public const SCRIPT_PATH = __DIR__ . "/Internal/task-runner.php";

private ?ContextFactory $contextFactory;

/**
* @param string $cacheClass Name of class implementing {@see Cache} to instantiate in each worker. Defaults
* to {@see LocalCache}.
Expand All @@ -24,7 +22,7 @@ final class DefaultWorkerFactory implements WorkerFactory
*/
public function __construct(
private ?string $bootstrapPath = null,
?ContextFactory $contextFactory = null,
private ?ContextFactory $contextFactory = null,
private string $cacheClass = LocalCache::class,
) {
$this->contextFactory = $contextFactory;
Expand Down
17 changes: 4 additions & 13 deletions src/Worker/DefaultWorkerPool.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,6 @@ final class DefaultWorkerPool implements WorkerPool
/** @var bool Indicates if the pool is currently running. */
private bool $running = true;

/** @var int The maximum number of workers the pool should spawn. */
private int $limit;

/** @var WorkerFactory A worker factory to be used to create new workers. */
private ?WorkerFactory $factory;

/** @var \SplObjectStorage A collection of all workers in the pool. */
private \SplObjectStorage $workers;

Expand All @@ -50,17 +44,14 @@ final class DefaultWorkerPool implements WorkerPool
*
* @throws \Error
*/
public function __construct(int $limit = self::DEFAULT_WORKER_LIMIT, ?WorkerFactory $factory = null)
{
public function __construct(
private int $limit = self::DEFAULT_WORKER_LIMIT,
private ?WorkerFactory $factory = null,
) {
if ($limit < 0) {
throw new \Error("Maximum size must be a non-negative integer");
}

$this->limit = $limit;

// Use the global factory if none is given.
$this->factory = $factory;

$this->workers = new \SplObjectStorage;
$this->idleWorkers = new \SplQueue;

Expand Down

0 comments on commit d491b02

Please sign in to comment.