-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
[WASI] WasiEventLoop to keep Task alive #106633
Conversation
Tagging subscribers to 'arch-wasm': @lewing |
424caaf
to
34baea9
Compare
- Pollable lifetime by lifetime of the Task
@dicej please review |
|
||
namespace System.Threading | ||
{ | ||
internal static class WasiEventLoop | ||
{ | ||
private static List<WeakReference<TaskCompletionSource>> s_pollables = new(); | ||
// TODO: if the Pollable never resolves and and the Task is abandoned |
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.
Here's my naive attempt at this. I'm sure yours is better, but one thing to make sure of is that we give all tasks a chance to run once any of them have been cancelled (see this comment). I can't tell if your code accounts for this.
FWIW, this is the code I've been using to test HttpClient
timeouts. It's paired with this server code.
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.
My solution will cancel the Task
synchronously when the CancellationTokenSource.Cancel
is called because of the CancellationTokenRegistration
callback.
And that could possibly trigger execution of other synchronous/inline continuations.
It seems to me, that synchronous cancellation is better. And it's enough to pass the test.
I added test similar to yours with some azure endpoint, which is not perfect, but I plan to fix it later.
src/libraries/System.Private.CoreLib/src/System/Threading/Wasi/generate-wasi-poll-bindings.sh
Outdated
Show resolved
Hide resolved
/ba-g CI timeouts, but the test WASI WBT which I care for passed |
WasiEventLoop
to not useWeakReference
- when the task is collected the loop could be infiniteGC.Collect()
to HTTP test to test it works nowTask.Delay()
RegisterWasiPollable
withCancellationToken
argument