# std.Io.Threaded: rework file reading to observe nonblocking flag · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/9f6152ae93037b7e69c14dba5691b146f670b3f8)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: 9f6152ae93037b7e69c14dba5691b146f670b3f8

Requested commit: 9f6152ae93037b7e69c14dba5691b146f670b3f8

Commit: 9f6152ae93037b7e69c14dba5691b146f670b3f8

Tree: fa53c32a68d063a771a617ce40bfd36838240780

Author: Andrew Kelley

Committer: Andrew Kelley

## Message

```
std.Io.Threaded: rework file reading to observe nonblocking flag

- batchAwaitAsync does blocking reads with NtReadFile (no APC, no event)
  when the nonblocking flag is unset, but still takes advantage of
  APCs when nonblocking flag is set.
- batchAwaitConcurrent returns error.ConcurrencyUnavailable when it
  encounters a file_read_streaming operation on a file in blocking mode.
- fileReadStreaming avoids pointlessly checking sync cancelation status
  when nonblocking flag is set, uses an APC with a done flag, and waits
  on that value to change in NtDelayExecution before returning.
- fix incorrect use of NtCancelIoFile (ntdll function prototype was
  wrong, leading to misuse)

```

## Parents

- [a9778e25496a148839d5de1024213ca96f39c5f8](https://git.cafe/gitcafe/zig/commit/a9778e25496a148839d5de1024213ca96f39c5f8?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/9f6152ae93037b7e69c14dba5691b146f670b3f8?format=markdown)
