src: add complement APIs for event loop integration#3299
Closed
zcbenz wants to merge 1 commit into
Closed
Conversation
41b227a to
18a1a9a
Compare
Member
|
Seems related to #3234 also? Since libuv is currently fully-synchronous, I don't think this seems the right approach right now. |
Contributor
Author
|
Yeah #3234 is also related, but it can not solve the problem of timers not working in event loop integration: the change of
How do you think about adding a new option to uv loop that, with it changes of watcher queue will implicitly cause an interruption to the polling of backend fd? uv_loop_configure(loop, UV_INTERRUPT_ON_WATCHER_QUEUE_CHANGE);In this way we don't need to expose a hook style API. |
Contributor
Author
|
I'm closing this PR in favor of #3308. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When integrating an uv event loop with other event loops, we usually listen to events on the backend fd of the uv event loop. However in libuv timers do not trigger events on the backend fd, and this would cause problem like, Node's
setTimeoutnot working in Electron. (See also #1565, #1651.)To solve this, we need to get notified whenever a timer is started, and then update the timeout when listening to backend fd. This PR adds the
uv_loop_set_timer_started_callbackAPI for this purpose.This PR is different from the current approach used in Electron (#1921), as the latter sends notifications for some unneeded cases.
I have added a test in
test/test-embed.cto demonstrate the problem of timers with event loop integration, and how this API can be used to fix it./cc @bnoordhuis