public function submit(Context $context, $work, int $priority = 0): Promise
    {
        $job = new class($context) extends Placeholder {

            public $priority;

            public $generator;
        };
        
        $job->priority = $priority;
        $job->generator = ($work instanceof \Generator) ? $work : Coroutine::generate($work, $context);
        
        for ($inserted = null, $count = \count($this->jobs), $i = 0; $i < $count; $i++) {
            if ($priority <= $this->jobs[$i]->priority) {
                $inserted = \array_splice($this->jobs, $i, 0, [
                    $job
                ]);
                
                break;
            }
        }
        
        if ($inserted === null) {
            $this->jobs[] = $job;
        }
        
        if ($this->running < $this->concurrency) {
            $this->running++;
            
            $context->getLoop()->defer(\Closure::fromCallable([
                $this,
                'executeNextJob'
            ]));
        }
        
        return $context->keepBusy($job->promise());
    }