I created a io_service in main thread, for dispatch user request. And i created another io_service in a thread_pool, run some sync work(like database query).
After main thread got some user request, it post a query into the io_service running in the thread_pool. After the query has been completed, query thread post a work to the main thread. But the next query cannot be handled until the last result was closed. So query thread need to wait main thread until it'll not using the result any more.
 
How to do it? Now I write some code with mutex and condition_variables. but is there any better choice with out such things?