Skip to content

Refactor cancellation of IOCP::OverlappedOperation#14754

Merged
straight-shoota merged 8 commits intocrystal-lang:masterfrom
straight-shoota:refactor/iocp-sleep
Aug 7, 2024
Merged

Refactor cancellation of IOCP::OverlappedOperation#14754
straight-shoota merged 8 commits intocrystal-lang:masterfrom
straight-shoota:refactor/iocp-sleep

Conversation

@straight-shoota
Copy link
Member

When an overlapped operation gets cancelled, we still need to wait for completion of the operation (with status ERROR_OPERATION_ABORTED) before it can be freed.
Previously we stored a reference to cancelled operations in a linked list and removed them when complete. This allows continuing executing the fiber directly after the cancellation is triggered, but it's also quite a bit of overhead.
Also it makes it impossible to allocate operations on the stack.

Cancellation is triggered when an operation times out.

The change in this patch is that after a timeout the fiber is suspended again, expecting completion via the event loop. Then the operation can be freed.

@straight-shoota straight-shoota added kind:refactor platform:windows Windows support based on the MSVC toolchain / Win32 API topic:stdlib:system labels Jun 25, 2024
@straight-shoota straight-shoota self-assigned this Jun 25, 2024
@straight-shoota straight-shoota added this to the 1.14.0 milestone Jul 13, 2024
@straight-shoota straight-shoota merged commit bddb53f into crystal-lang:master Aug 7, 2024
@straight-shoota straight-shoota deleted the refactor/iocp-sleep branch August 7, 2024 14:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind:refactor platform:windows Windows support based on the MSVC toolchain / Win32 API topic:stdlib:system

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants