Example #1
0
 /**
  * @param WorkerBootstrapProfile $bootstrapProfile
  * @param string                 $implementationExpression
  * @param int|null               $workerCount
  *
  * @throws Exception\InvalidArgumentException
  * @throws Exception\RuntimeException
  */
 protected function __construct(WorkerBootstrapProfile $bootstrapProfile, $implementationExpression, $workerCount = null)
 {
     $workerCount = $workerCount === null ? self::getProcessorCount() : intval($workerCount);
     if ($workerCount <= 0) {
         throw new Exception\InvalidArgumentException('The worker count must be a strictly positive number !');
     }
     $this->workers = [];
     while ($workerCount-- > 0) {
         $this->workers[] = Worker::withExpression($bootstrapProfile, $implementationExpression);
     }
 }
Example #2
0
 /**
  * @param string $implementationExpression
  *
  * @return Worker
  */
 public function createWorkerWithExpression($implementationExpression)
 {
     return Worker::withExpression($this->bootstrapProfile, $implementationExpression);
 }