boost asio 性能与线程安全性
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: ?同一個(gè)socket上, 不能 read write讀寫不能并發(fā)。。。。 !!!!???? 這個(gè)感覺不可能吧。。。那也太弱智了。。
====確實(shí)不能對(duì)同一個(gè)socket同時(shí)讀寫,socket能封裝了basic_socket_stream, 該類的對(duì)象不能支持同時(shí)進(jìn)行讀寫操作。ps, fstream也不能支持同時(shí)讀寫吧。。
http://stackoverflow.com/questions/4078484/using-boost-sockets-do-i-need-only-one-io-service
只強(qiáng)調(diào), 不能 對(duì)同一個(gè)socket同時(shí)多讀, 或者同時(shí)多寫。
http://stackoverflow.com/questions/6161725/boostasio-threadpool-vs-io-service-per-cpu-design
性能遞升。。。
http://en.highscore.de/cpp/boost/asio.html#asio_networkprogramming
high score boost里面有boost asio的用法
1) single thread && single io_service, 最簡(jiǎn)單, 性能最一般
2) multithread && single io_service
3) io_service per thread. ?multi io_service.
這三個(gè)性能應(yīng)該也是遞增的。。。
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能使異步切碎的邏輯看起來(lái)像同步的方式寫代碼。
但是coroutine不能支持多線程, 只能一個(gè)ioservice一個(gè)線程的方式。
總結(jié)
以上是生活随笔為你收集整理的boost asio 性能与线程安全性的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: samba 安装配置
- 下一篇: 锁与高6)并发