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

是否支持多线程的请求? #9

Closed PL23K closed 4 years ago

PL23K commented 4 years ago

不知道这个库跟“Pistache”比较怎么样?Pistache在自我介绍的时候有提多线程支持,不知道webcc是否支持?

PL23K commented 4 years ago

我通过项目中的helloworld示例,修改server.run(10); HelloWorld视图中加入线程延时并打印运行时间,发现,同时发起两个请求时,请求并不是并行执行的,还是一个请求执行完了之后再执行第二个请求。 所以server.run(10)中的worker个数和并发请求的处理无关?

PL23K commented 4 years ago

请问如何让server能够处理并发?

xiaobingcaicai commented 4 years ago

同问

sprinfall commented 4 years ago

谢谢反馈,正在调查原因,以前没有这个问题。我会尽快解决。

sprinfall commented 4 years ago

我测试过了,没有问题,诸位可以参考新加的 examples/concurrency_test.cc 里的写法,每次调用都创建一个新的 ClientSession,不要在多个线程间复用 ClientSession 对象。 此外,程序第一次运行可能会慢一些,这是 ASIO 或底层 socket 的问题,暂时我还不太清楚。

PL23K commented 4 years ago

thinks