Boost logo

Boost Users :

Subject: [Boost-users] [asio] Using io_service::poll() without pthread locking and unlocking
From: 谢任中 (joshchia_at_[hidden])
Date: 2015-10-29 06:10:10


I'm using boost::asio to do some TCP socket communication from a
single-threaded program. The program performs asynchronous reads and writes
and keeps calling io_service::poll() from a busy loop.

I noticed from callgrind profiling that a significant portion of time is
spent on pthread locking and unlocking from io_service::poll(). If I can
get rid of the lock operations, the performance will improve significantly.
Is there a way to get io_service to not use locks other than hacking the
source code? It's a single-threaded application so the locking is
unnecessary.

The main reason I'm using asio is for the abstraction that allows me to
write clean, simple, code, and hope I don't have to give up performance for
simplicity.

Josh



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net