Skip to content

Commit

Permalink
Allow thread pool autoloader to be empty
Browse files Browse the repository at this point in the history
  • Loading branch information
matyhtf committed Sep 30, 2024
1 parent fa7b522 commit 068752d
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/core/Thread/Pool.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,13 @@ public function start(array $arguments = []): void
}
}
}
if (empty($this->autoloader)) {
throw new \Exception('autoload file not found');

if ($this->autoloader) {
$this->proxyFile = dirname($this->autoloader) . '/thread_runner.php';
} else {
$this->proxyFile = dirname($this->classDefinitionFile) . '/thread_runner.php';
}

$this->proxyFile = dirname($this->autoloader) . '/thread_runner.php';
if (!is_file($this->proxyFile)) {
$script = '<?php' . PHP_EOL;
$script .= '$arguments = Swoole\Thread::getArguments();' . PHP_EOL;
Expand All @@ -109,7 +111,7 @@ public function start(array $arguments = []): void
$script .= '$classDefinitionFile = $arguments[3];' . PHP_EOL;
$script .= '$running = $arguments[4];' . PHP_EOL;
$script .= '$threadArguments = array_slice($arguments, 5);' . PHP_EOL;
$script .= 'require_once $autoloader;' . PHP_EOL;
$script .= 'if ($autoloader) require_once $autoloader;' . PHP_EOL;
$script .= 'if ($classDefinitionFile) require_once $classDefinitionFile;' . PHP_EOL;
$script .= '$runnable = new $runnableClass($running);' . PHP_EOL;
$script .= 'try { $runnable->run($threadArguments); }' . PHP_EOL;
Expand Down

0 comments on commit 068752d

Please sign in to comment.