http://stackoverflow.com/questions/12794107/why-do-i-need-strand-per-connection-when-using-boostasio/12801042
http://www.boost.org/doc/libs/1_51_0/doc/html/boost_asio/overview/core/strands.html
url1: 同一个socket上, 不能 read write读写不能并发。。。。 !!!!???? 这个感觉不可能吧。。。那也太弱智了。。
====确实不能对同一个socket同时读写,socket能封装了basic_socket_stream, 该类的对象不能支持同时进行读写操作。ps, fstream也不能支持同时读写吧。。
http://stackoverflow.com/questions/4078484/using-boost-sockets-do-i-need-only-one-io-service
只强调, 不能 对同一个socket同时多读, 或者同时多写。
http://stackoverflow.com/questions/6161725/boostasio-threadpool-vs-io-service-per-cpu-design
性能递升。。。
- single thread and a single
io_service
- multiple threads, each invoking
io_service::run()
from a singleio_service
. Use strands for handlers that require access to shared data structures. -
io_service
per cpu
http://en.highscore.de/cpp/boost/asio.html#asio_networkprogramming
high score boost里面有boost asio的用法
1) single thread && single io_service, 最简单, 性能最一般
2) multithread && single io_service
3) io_service per thread. multi io_service.
这三个性能应该也是递增的。。。
http://stackoverflow.com/questions/11010530/do-we-need-multiple-io-service-per-thread-for-threaded-boostasio-server-with/11011080#11011080
single thread && single io_service性能肯定是不够的。
boost asio example
HTTP Server 2
An HTTP server using an io_service-per-CPU design.
HTTP Server 3
An HTTP server using a single io_service and a thread pool calling io_service::run()
.
http://stackoverflow.com/questions/8557067/thread-safe-coroutines-with-asio
http://www.crystalclearsoftware.com/soc/coroutine/coroutine/coroutine_thread.html
coroutine能使异步切碎的逻辑看起来像同步的方式写代码。
但是coroutine不能支持多线程, 只能一个ioservice一个线程的方式。