We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
// routes/web.php $router->get('/', function() { $tasks[] = mt_rand(1000, 9999); //任务1 $tasks[] = mt_rand(1000, 9999); //任务2 $tasks[] = mt_rand(1000, 9999); //任务3 var_dump($tasks); //等待所有Task结果返回,超时为10s $results = app('swoole')->taskWaitMulti($tasks, 10.0); if (! isset($results[0])) { echo "任务1执行超时了\n"; } if (isset($results[1])) { echo "任务2的执行结果为{$results[1]}\n"; } if (isset($results[2])) { echo "任务3的执行结果为{$results[2]}\n"; } });
执行结果:任务1执行超时了
任务1执行超时了
The text was updated successfully, but these errors were encountered:
因为LaravelS中封装了Hhxsv5\LaravelS\Swoole\Task\Task Hhxsv5\LaravelS\Swoole\Task\Event,会忽略其他类型的Task,onTask中不会return结果,故taskWaitMulti()返回的是false。
Hhxsv5\LaravelS\Swoole\Task\Task
Hhxsv5\LaravelS\Swoole\Task\Event
关于taskWaitMulti(),LaravelS应该可以封装一个MultiTask对象,这个我本地测试看看,如果可行,会发布新版支持。
Sorry, something went wrong.
节后能支持吗😀
No branches or pull requests
执行结果:
任务1执行超时了
The text was updated successfully, but these errors were encountered: