Home > PHP Framework > Swoole > Does swoole not have multi-threading?

Does swoole not have multi-threading?

Release: 2019-12-23 13:33:22
Original
2624 people have browsed it

Does swoole not have multi-threading?

Since the PHP language does not support multi-threading, Swoole uses multi-process mode. There is process memory isolation in multi-process mode. When global variables and super-global variables are modified in the working process, it will be invalid in other processes.

Does swoole not have multi-threading?

Reactor thread

The main process of Swoole\Server is a multi-threaded program. There is a very important group of threads called Reactor threads. It is the thread that actually handles TCP connections and sends and receives data.

After accepting a new connection, Swoole's main thread will assign the connection to a fixed Reactor thread, and this thread will be responsible for monitoring the socket. Read the data when the socket is readable, perform protocol analysis, and deliver the request to the Worker process. Send data to the TCP client when the socket is writable.

The allocation calculation method is fd % serv->reactor_num

Recommended learning: swoole video tutorial

The above is the detailed content of Does swoole not have multi-threading?. 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