views:

111

answers:

1

According to the Boost Documentation, having multiple threads call io_service::run() sets up a pool of threads that the IO service can use for performing asynchronous tasks. It explicitly states that all threads that have joined the pool are considered equivalent.

Does this imply that it is not possible to have a separate thread for reading from a socket and a separate one for writing? If it is possible, how would I implement this?

+3  A: 

Any thread that calls io_service::run() can be used to invoke asynchronous handlers. But you can't specifically specify which thread executes which type of operation. For example, if you call io_service::run() in 2 background threads, and you were to call socket::async_send and socket::async_receive in a main thread, your handlers will be executed in any background thread that is currently available. So yes, all threads are basically considered equivalent, and may be used for any asynchronous operation.

Charles Salvia