dotnet / dotnet/runtime

Support registering wait handle callbacks in the managed wait subsystem.

Open
#131,574 1 comment 0 reactions 2 assignees Claimed by @VSadov View on GitHub
area-System.Threading
Dominant language
C#
Stars
18.3k
Forks
5.6k
PR merge metrics
PR metrics pending

Description

On non-Windows platforms, `WaitHandle`s do not wrap kernel objects, but they are implemented in managed code. This means that it should be possible to implement `RegisterWaitForSingleObject` by registering a callback directly on the `WaitHandle`, and queueing it to the thread pool when the wait handle gets signaled. With this and #131196, we can remove `PortableThreadPool.WaitThread`.

One complication would be with named cross-process mutexes which use shared memory, but `RegisterWaitForSingleObject` already has unclear semantics when used with mutexes. We can throw `NotSupportedException` in this case.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.