Theworkerman framework itself does not support coroutines.
Coroutines are not processes or threads, and their execution process is more similar to subroutines, or function calls without return values.
A program can contain multiple coroutines, which can be compared with a process containing multiple threads, so let’s compare coroutines and threads below. We know that multiple threads are relatively independent and have their own context, and switching is controlled by the system; coroutines are also relatively independent and have their own context, but their switching is controlled by themselves. Switching from the current coroutine to other coroutines is controlled by the current coroutine. to control.
Recommendation: workerman tutorial
The bottom layer of Workerman supports swoole as an event driver, which means that swoole's coroutine can be used directly in Workerman.
Install the swoole extension, and then call Worker::$eventLoopClass = 'Workerman\Events\Swoole'; before calling Worker::runAl();
The swoole version should not be too Low, because many developers have reported that versions that are too low will have coredumps.
The above is the detailed content of Does workerman support coroutines?. For more information, please follow other related articles on the PHP Chinese website!