Skip to content
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

Add kj::yieldUntilWouldSleep() and EventLoopLocal #2167

Open
wants to merge 4 commits into
base: v2
Choose a base branch
from

Conversation

kentonv
Copy link
Member

@kentonv kentonv commented Oct 22, 2024

This goes further than kj::yieldUntilQueueEmpty() by also making sure the OS-level I/O queue (e.g. epoll) is empty.

Also in this PR: EventLoopLocal, which is like thread_local but attached to the current EventLoop.

Hint: These are things needed for implementing green threads.

@kentonv kentonv marked this pull request as draft October 27, 2024 16:06
@kentonv kentonv removed the request for review from ObsidianMinor October 27, 2024 16:07
@kentonv
Copy link
Member Author

kentonv commented Oct 27, 2024

Reverted to draft. Need to do this a bit differently.

kentonv added a commit to cloudflare/workerd that referenced this pull request Oct 27, 2024
kentonv added a commit to cloudflare/workerd that referenced this pull request Oct 29, 2024
This goes further than kj::yieldUntilQueueEmpty() by also making sure the OS-level I/O queue (e.g. `epoll`) is empty.
Does the same thing as WaitScope::cancelAllDetached(), but sometimes it's easier to access the `EventLoop`.
It's like thread-local variables, except they are local to the current EventLoop instead.
The node we are waiting on can actually be destroyed and replaced during the wait -- that's why we do `setSelfPointer(&node)`, to allow it to be replaced. But `currentInner` was being set to point at the node itself. So this could become dangling. Instead, it should point at the self-pointer, so that it reflects any replacements.
kentonv added a commit to cloudflare/workerd that referenced this pull request Nov 2, 2024
@kentonv kentonv marked this pull request as ready for review November 2, 2024 23:42
@kentonv kentonv changed the title Add kj::yieldUntilWouldSleep(). Add kj::yieldUntilWouldSleep() and EventLoopLocal Nov 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant