ZLMediaKit / ZLToolKit

一个基于C++11的轻量级网络框架,基于线程池技术可以实现大并发网络IO
MIT License
1.98k stars 588 forks source link

zltookkit Usage #225

Open HalcyonHuang opened 8 months ago

HalcyonHuang commented 8 months ago

I plan to use zltoolkit for development, the scenario is similar to: TcpClient receives > processes > tcp replies. Since the processing is time-consuming, if I use one thread for sending and receiving, and multiple threads for processing messages.

  1. Processing takes a certain amount of time, should network sending and receiving be separated from message processing in different threads? Since zltoolkit uses a thread pool, how to ensure that message processing and tcp sending and receiving are performed in different threads.

  2. If multiple threads are used for message processing, the processing time after receiving is uncertain. There are order requirements for sending and receiving, such as the receiving order is message 1 first, then message 2, then message 3, and the sending order requires sending message 1 first, then message 2, and then sending message 3. Will using a thread pool cause order problems?

打算使用zltookkit来做开发,场景类似: TcpClient接收 > 处理 > tcp回复 ,由于处理比较耗时,假如我用一个线程来做收发,多个线程来处理报文。

1.处理有一定的时间消耗,是不是应该把网络收发,和报文处理分开不同线程处理?由于zltoolkit用的线程池,怎么保证报文处理和tcp收发再不同线程进行.

2.假如用多个线程来进行报文处理,接收后的处理耗时不定 。 收发有顺序要求比如 接收顺序为 先报文1 然后报文2 然后报文3 ,发送顺序要求 先发送报文1 ,然后报文2,再发送报文3。使用线程池会不会导致顺序问题?

TRANS_BY_GITHUB_AI_ASSISTANT