-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement ControlledExecution API #71661
Implement ControlledExecution API #71661
Conversation
Note regarding the This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, to please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change. |
src/coreclr/System.Private.CoreLib/src/System/Threading/Thread.CoreCLR.cs
Outdated
Show resolved
Hide resolved
Looks good in general. I think the remaining open issues are:
|
The failure in "Libraries Test Run checked coreclr Linux_musl arm64 Release" looks similar to this one: #66413 (comment). |
...lr/System.Private.CoreLib/src/System/Runtime/CompilerServices/ControlledExecution.CoreCLR.cs
Outdated
Show resolved
Hide resolved
2be3526
to
f93ded4
Compare
src/coreclr/System.Private.CoreLib/src/System/Runtime/ControlledExecution.CoreCLR.cs
Show resolved
Hide resolved
src/coreclr/System.Private.CoreLib/src/System/Runtime/ControlledExecution.CoreCLR.cs
Outdated
Show resolved
Hide resolved
src/coreclr/System.Private.CoreLib/src/System/Runtime/ControlledExecution.CoreCLR.cs
Outdated
Show resolved
Hide resolved
src/coreclr/System.Private.CoreLib/src/System/Runtime/ControlledExecution.CoreCLR.cs
Outdated
Show resolved
Hide resolved
src/coreclr/System.Private.CoreLib/src/System/Runtime/ControlledExecution.CoreCLR.cs
Outdated
Show resolved
Hide resolved
src/coreclr/System.Private.CoreLib/src/System/Runtime/ControlledExecution.CoreCLR.cs
Outdated
Show resolved
Hide resolved
src/coreclr/System.Private.CoreLib/src/System/Runtime/ControlledExecution.CoreCLR.cs
Outdated
Show resolved
Hide resolved
src/coreclr/System.Private.CoreLib/src/System/Runtime/ControlledExecution.CoreCLR.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Runtime/tests/System/Runtime/ControlledExecutionTests.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Runtime/tests/System/Runtime/ControlledExecutionTests.cs
Outdated
Show resolved
Hide resolved
src/coreclr/System.Private.CoreLib/src/System/Runtime/ControlledExecution.CoreCLR.cs
Outdated
Show resolved
Hide resolved
The failures in the last run are unrelated: |
src/coreclr/System.Private.CoreLib/src/System/Runtime/ControlledExecution.CoreCLR.cs
Outdated
Show resolved
Hide resolved
src/coreclr/System.Private.CoreLib/src/System/Runtime/ControlledExecution.CoreCLR.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Thank you for very valuable feedback! |
#73399 enabled this API on non-Windows operating systems. |
Implementation for API proposal #69622:
The
Run
method runs the specified action and allows to abort it asynchronously using the provided cancellation token. When cancellation is requested, the registeredExecution.Abort
callback calls theThread::UserAbort
runtime function, which is currently employed by the debugger to abort function evaluation. That function sets theTS_AbortRequested
flag on the thread to abort, which causes the runtime to throw an asynchronousThreadAbortException
. This exception may be caught by the code being executed; however, it is automatically rethrown at the end ofcatch
blocks. However, the code may catch it and throw an exception of a different type.The
Run
method resets theTS_AbortRequested
flag on the current thread if execution of the action has been aborted, which stops rethrowing the exception. It also catches theThreadAbortException
and normalizes it to anOperationCancelledException
.Recursive
ControlledExecution.Run
calls are not supported at present — we can support them if there is a valid scenario.An example of using this API:
FYI: @mangod9 @janvorli