sprinfall / webcc

Lightweight C++ HTTP client and server library based on Asio for embedding purpose.
GNU Lesser General Public License v3.0
270 stars 61 forks source link

如何复用io_service #25

Open windflowerly opened 2 years ago

windflowerly commented 2 years ago

我的项目中也使用了io_service.如何才能复用项目中的io_service

windflowerly commented 2 years ago

现在新版的asio用io_context替换掉了io_service。问题改为如何复用项目中已有的io_context

sprinfall commented 2 years ago

现在新版的asio用io_context替换掉了io_service。问题改为如何复用项目中已有的io_context

不必复用,也不该复用,每一个 webcc::ClientSession 都有一个 io_context,跑在一个单独的线程里。 你自己项目里的 io_context 通常也应该跑在一个线程里。