Home >PHP Framework >Workerman >Does workerman support coroutines?

Does workerman support coroutines?

尚
Original
2019-12-23 10:06:283169browse

Does workerman support coroutines?

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn