I'm utilising Swoole concurrency in a Laravel project.
In the task worker I need to resolve a class (because the function passed to the task worker needs to be serialized, I can't pass the class to the worker - let me know if I'm incorrect in this assumption).
The resolution of this class takes ~400ms. When resolving the same class outside of the task worker , is is less than a millisecond to resolve.
I wanted to understand what is causing this, and if there are any approaches or patterns that could achieve a resolution in <1ms.
// <1ms
$class = resolve(MyClass::class);
Octane::concurrently([
fn () => self::func(),
...
]);
private static function func()
{
// 400ms - Why is this?
$class = resolve(MyClass::class);
}
Thanks in advance!