I am considering using asio to perform "overlapped" (completion ports) style IO on a windows "device handle" created with CreateFile(...overlapped...)
I have quite a particular design though, because of specifics of my application I must maintain a different thread pool for performing the actual processing of data(work pool) and a pool (a very small one, could be just one thread maybe) of actual IO completions triggered by the processing pool.
Basically, at the beginning I want to trigger a handful of IO requests to my device that are initiated from IO pool. When these complete I notify a scheduling component that POSTS the completion packets content to different threads in the work pool. These completion notifications return quickly because actual processing will happen in work pool -> and from a particular work pool thread after processing takes place a new "read" is initiated that should trigger completion on the io pool.
Is this dissociation possible using windows::stream_handle ? In general seems the asio API associates read completions with the same io_service associated with the stream object.
EDIT Been a long time now, as I've already implemented the approach. I've updated my response to reflect my choices.
I create the "device" handle using windows specific function:
HANDLE file_handle = CreateFile(... FILE_FLAG_OVERLAPPED ...);
I can associate/register the handle with my ioService so that all overlapped requests to the device are handled by one of the ioService thread(s).
error_code ec; auto &io_service_impl = use_service(ioservice); io_service_impl.register_handle(file_handle, ec);
Then I can use the asio overlapped to initiate async IO from a different thread than ioService.run(), making it trigger completion in the io service thread(s):
For reference a device read implementation:
}