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