src/sys/ioqueue/iocp

Source   Edit  

Windows-specific implementation of ioqueue.

Shares the same queue and interface with ioqueue. Most users do not need to import this module as it is exported by ioqueue.

Types

UnregisteredHandleDefect = object of Defect

A wait(fd, overlapped) was attempted before the fd is registered.

If an operation is done before the fd is registered into the queue, the queue might not receive the completion result, causing spontaneous hangs.

To avoid this, make sure that the fd is registered before performing any overlapped operation.

Source   Edit  

Procs

proc newUnregisteredHandleDefect(): ref UnregisteredHandleDefect {....raises: [],
    tags: [], forbids: [].}
Source   Edit  
proc wait(c: Continuation; fd: AnyFD; overlapped: ref OVERLAPPED): Continuation

Wait for the operation associated with overlapped to finish.

The fd must be registered via persist() with the queue before the operation associated with overlapped is done or there will be a high chance that the event will never arrive. A limited form of sanity check is available via UnregisteredHandleDefect.

Only one continuation can be queued for any given fd. If more than one is queued, ValueError will be raised. This limitation might be lifted in the future.

Notes:

  • The fd should be unregistered before closing so that resources associated with any pending operations are released.

Tips: For submitting the Overlapped structure via an operation in the first place, just create a ref Overlapped, fill it with information as needed, then passes its address as the lpOverlapped parameter.

Source   Edit  
proc wait(c: Continuation; handle: Handle[AnyFD]; overlapped: ref OVERLAPPED): Continuation

Wait for the operation associated with overlapped to finish.

This is an overload of wait for use with Handle[T].

Source   Edit  
proc wait(fd: AnyFD; overlapped: ref OVERLAPPED) {.cpsMustJump, cpsMagicCall.}
Source   Edit  
proc wait(handle: Handle[AnyFD]; overlapped: ref OVERLAPPED) {.cpsMustJump,
    cpsMagicCall.}
Source   Edit