Skip to content

Use NtAssociateWaitCompletionPacket to register wait handle callbacks on Windows. #131196

Description

@teo-tsirpanis

Since Windows 8, the Windows thread pool has been able to serve an unbounded number of wait callbacks with a single thread, by using the NtAssociateWaitCompletionPacket API to register wait handle completion packets on an I/O completion port. We can make use of this API in the portable thread pool, by leveraging its existing I/O completion port. Other environments like Go and Bun are using it too.

If it's OK to do, should we keep the existing PortableThreadPool.WaitThread mechanism as a fallback if NtAssociateWaitCompletionPacket does not exist? It should exist on all Windows versions currently supported by .NET, barring potential outliers like Xbox.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions