I believe the async operations on file handles opened with FILE_FLAG_OVERLAPPED, should be marked as "unsafe" when the ReadFile/WriteFile family of functions are used in the overlapped mode. Because, the OVERLAPPED structure and the buffer must remain untouched and live until the async operation completes. This cannot be guaranteed by the compiler when ownership is passed to the kernel and the references are casted away, Therefore it is up to the caller to maintain this guarantee manually.
However, it is safe in synchronous mode, and it would be unfair to mark this as unsafe as collateral to when meeting the requirments used in async mode. I would suggest splitting the methods as read_file/write_file and read_file_overlapped/write_file_overlapped where the overlapped alternatives would be marked as unsafe.
Hello,
I believe the async operations on file handles opened with FILE_FLAG_OVERLAPPED, should be marked as "unsafe" when the ReadFile/WriteFile family of functions are used in the overlapped mode. Because, the OVERLAPPED structure and the buffer must remain untouched and live until the async operation completes. This cannot be guaranteed by the compiler when ownership is passed to the kernel and the references are casted away, Therefore it is up to the caller to maintain this guarantee manually.
However, it is safe in synchronous mode, and it would be unfair to mark this as unsafe as collateral to when meeting the requirments used in async mode. I would suggest splitting the methods as
read_file/write_file
andread_file_overlapped/write_file_overlapped
where the overlapped alternatives would be marked as unsafe.