function submit(\Threaded $work) {
        if($this->timer === null) {
            $this->attachTimer();
        }
        
        $worker = ($this->freeWorkers->count() > 0 ? $this->freeWorkers->dequeue() : null);
        if(!$worker) {
            if(\count($this->workers) >= $this->size) {
                $iwork = new \CharlotteDunois\Phoebe\InternalWork($work);
                $this->workQueue->enqueue($iwork);
                
                return $iwork->getDeferred()->promise();
            }
            
            $worker = $this->spawnWorker();
        }
        
        $worker = $this->checkAlive($worker);
        
        $this->busyWorkers->add($worker);
        $worker->stack($work);
        
        if($this->messenger->usesSockets()) {
            $msg = new \CharlotteDunois\Phoebe\Message('internal-worker-stack-increased', null);
            $this->sendMessageToWorker($worker, $msg);
        }
        
        return \React\Promise\resolve($worker);
    }
function submit(\Threaded $work) {
        if($this->timer === null) {
            $this->attachTimer();
        }
        
        $worker = ($this->freeWorkers->count() > 0 ? $this->freeWorkers->dequeue() : null);
        if(!$worker) {
            if(\count($this->workers) >= $this->size) {
                $iwork = new \CharlotteDunois\Phoebe\InternalWork($work);
                $this->workQueue->enqueue($iwork);
                
                return $iwork->getDeferred()->promise();
            }
            
            $worker = $this->spawnWorker();
        }
        
        $worker = $this->checkAlive($worker);
        
        $this->busyWorkers->add($worker);
        $worker->stack($work);
        
        if($this->messenger->usesSockets()) {
            $msg = new \CharlotteDunois\Phoebe\Message('internal-worker-stack-increased', null);
            $this->sendMessageToWorker($worker, $msg);
        }
        
        return \React\Promise\resolve($worker);
    }
function submit ( \ Threaded $ work ) { if ( $ this -> timer === null ) { $ this -> attachTimer ( ) ; } $ worker = ( $ this -> freeWorkers -> count ( ) > 0 ? $ this -> freeWorkers -> dequeue ( ) : null ) ; if ( ! $ worker ) { if ( \ count ( $ this -> workers ) >= $ this -> size ) { $ iwork = new \ CharlotteDunois \ Phoebe \ InternalWork ( $ work ) ; $ this -> workQueue -> enqueue ( $ iwork ) ; return $ iwork -> getDeferred ( ) -> promise ( ) ; } $ worker = $ this -> spawnWorker ( ) ; } $ worker = $ this -> checkAlive ( $ worker ) ; $ this -> busyWorkers -> add ( $ worker ) ; $ worker -> stack ( $ work ) ; if ( $ this -> messenger -> usesSockets ( ) ) { $ msg = new \ CharlotteDunois \ Phoebe \ Message ( 'internal-worker-stack-increased' , null ) ; $ this -> sendMessageToWorker ( $ worker , $ msg ) ; } return \ React \ Promise \ resolve ( $ worker ) ; }
Submits the work to a worker. Resolves with the worker who accepted the job.
@param \Threaded  $work
@return \React\Promise\ExtendedPromiseInterface
Submits the work to a worker . Resolves with the worker who accepted the job .