go/doc/next/6-stdlib/99-minor/os/15388.md

926 B

On Windows, [NewFile] now supports handles opened for asynchronous I/O (that is, [syscall.FILE_FLAG_OVERLAPPED] is specified in the [syscall.CreateFile] call). These handles are associated with the Go runtime's I/O completion port, which provides the following benefits for the resulting [File]:

  • I/O methods ([File.Read], [File.Write], [File.ReadAt], and [File.WriteAt]) do not block an OS thread.
  • Deadline methods ([File.SetDeadline], [File.SetReadDeadline], and [File.SetWriteDeadline]) are supported.

This enhancement is especially beneficial for applications that communicate via named pipes on Windows.

Note that a handle can only be associated with one completion port at a time. If the handle provided to [NewFile] is already associated with a completion port, the returned [File] is downgraded to synchronous I/O mode. In this case, I/O methods will block an OS thread, and the deadline methods have no effect.