Source: http://blog.csdn.net/pud_zha/article/details/37561011
Work is a small helper class that supports only constructors and destructors. (There is also a get_io_service returned by the associated Io_service) when constructing a work, outstanding_work_+1, so that io.run when the completion of all asynchronous messages after the judgment Outstanding_work_ will not be 0, Therefore, it will continue to call GetQueuedCompletionStatus and block on this function.
And the destructor will be 1, and determine if it is 0, if so, then post exit message to GetQueuedCompletionStatus let it exit.
So if work is refactored, io.run exits normally after all messages have been processed. Work if you do not refactor, the Io.run will run without exiting. If the user calls Io.stop directly, it causes Io.run to exit immediately.
It is particularly important to note that work provides a copy constructor so that it can be used directly anywhere. For a io_service, how many work instances are associated, then Outstanding_work_ + 1 How many times, only work connected to the same io_service is all
After destruction, io.run exits normally after all message processing has ended.