In same request, Context::getCoroutineId will return diffirent value when using it on different coroutines.
This problem is easy to make a mistake when using coroutines with laravel-swoole.
For example is below:
// ...
$request1 = $sandbox->getRequest();
go(function () use ($sandbox) {
// $request1 and $request2 are different reference because coroutine ids are not same.
$request2 = $sandbox->getRequest();
});
// ...
and another way:
// ...
$value1 = Context::getData('foo');
go(function () use ($sandbox) {
// $value1 and $value2 are different reference because coroutine ids are not same.
$value2 = Context::getData('foo');
});
// ...
In same request,
Context::getCoroutineId
will return diffirent value when using it on different coroutines. This problem is easy to make a mistake when using coroutines with laravel-swoole.For example is below:
and another way:
This PR is fixed it.