I'm implementing timeouts according to suggestion placed here
http://lists.boost.org/Archives/boost/2007/04/120339.php

because I still don't understand fully how io_service work I have
question:

is this way of implementation of timeout safe when I'm using pool of
threads for one io_service?

That function assumes the io_service associated with your socket is *stopped*, so it cannot run either in one thread or in multiple threads. Note that it is an async. implementation for *synchronous* use, and when you use sync. i/o you do not explicitly run io_service:

io_service io;
tcp::socket sock(io);
// open socket, define your buffer..., then:
read_with_timeout(sock, buffer);
 
But if you've already got an async. design, you don't need workarounds to implement timeouts - just use deadline_timer in the straightforward way.