Skip to content
This repository has been archived by the owner on Jun 22, 2021. It is now read-only.

What conditions will cause the loop to wake up from uv_async_send? #194

Open
morrisonlevi opened this issue Apr 5, 2021 · 1 comment
Open

Comments

@morrisonlevi
Copy link

I have a multi-threaded application, where one thread runs an event loop. If another thread calls uv_async_send, under what conditions will event loop thread wake up and trigger the callback?

Asking because I will need to block until the callback has actually executed, and need to know what sort of guarantees there are on what will wake it up. I could not find any guarantees in the docs.

@bnoordhuis
Copy link
Member

"Needs to block" is kind of ambiguous but I take it to mean the waker thread blocks until it gets an answer from the event loop thread?

The short answer is "always", provided you call uv_run(), your code returns control to the event loop (i.e., no busy loops), and you keep the uv_async_t handle open.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants