Home > PHP Framework > Workerman > body text

Does workerman support coroutines?

Release: 2019-12-23 10:06:28
Original
2880 people have browsed it

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!