2015-09-06 16:31:00 UTC
I'm trying to use io_service to build a replacement of Windows
::WaitForMultipleObjects event loop in my application. The reason is simple
- I want to use asio networking, but don't want to create an extra thread
for that. So I'm uniting all in io_service by utilizing
boost::asio::windows::object_handle to wrap HANDLEs from existing codebase.
And I have a problem here:
asio::windows::object_handle does take ownership of the HANDLE passed to
it. I.e. it closes a handle in destructor and there's no way to prevent
this. In my case, I already have a quite big application written in a way
that it manages HANDLE ownership by itself, so ownership is a problem.
How about adding a method like "detach()" to asio::windows::basic_handle?
This method can make object to forget about a HANDLE, i.e. return object
into a default-constructed state. I believe this functionality will be
useful for other users as well.
If the idea is acceptable, I can provide a patch.