Comments (5)
Is that indeed a possible sequence of execution? If so, I suggest replacing the text "within a short period of time" with "for the given async handle", making it clearer that the strongest guarantee made is that the callback will be executed once, ever.
No. At least on Unix, uv_async_send
will mark the handle as "pending" using atomic ops and when the callback is executed it's unmarked. As a result, if the callback was called, next time you call uv_async_send
you'll get the callback called again. If you call uv_async_send
5 times in a row, however, it's only guaranteed that your callback is called once.
If uv_async_send actually makes stronger guarantees, then please document them precisely. For example, a useful stronger guarantee would be that the callback is executed consistent with a model where uv_async_send atomically sets a "needs execution" flag, and the event loop atomically resets this flag before running the callback. That would rule out the sequence of execution above.
Async handles don't have strong guarantees, that's the whole point. People have used async handles to try to send data from one thread to the loop thread by attaching a void* data pointer to the request and calling uv_async_send
. This doesn't work and won't work for the reasons I mention above. The only guarantee is that your callback will be called once, but once the callback is called the story begins again.
If you feel this can be fursther clarified please do send a PR with a fix for the documentation.
from libuv.
Can't we just try to make it issue as many callbacks as there were function calls?
People are constantly confused.
from libuv.
@txdv that's uv_callback
. For 1.x this is what we have. Even if we could make it issue the right amount of callbacks, it wouldn't help much because you cannot attach data to them anyway. In uv_callback
I tried to solve both problems.
from libuv.
People have used async handles to try to send data from one thread to the loop thread by attaching a void* data pointer to the request and calling uv_async_send
His description mislead me a bit. I don't understand why people have so much trouble with that. Maybe we should add an object which wraps async and provides them the functionality so they stop with these posts.
from libuv.
@jfirebaugh can you have a look at #122 ?
from libuv.
Related Issues (20)
- Compilation warning: C++ comments are not allowed in ISO C90
- FreeBSD 13 builds are failing due to KINFO_FILE_SIZE undefined HOT 5
- uv_run hangs on macOS arm64/Rosetta in x86_64 docker container HOT 18
- Export "selected" CMake target for Libuv HOT 2
- io_uring support leads to crashes on ppcle64 machines. HOT 12
- Cannot make above v1.44.2
- windows: support launching executables with runas permissions HOT 2
- windows: misleading comments in tty.c
- macos: restoring signal disposition doesn't work as flags are not propagated HOT 7
- win: incorrect implementation of kill(0) / ESRCH
- Segment fault when run tty test HOT 4
- GPG keys of maintainers can't be retrieved from https://github.com/ nor https://libuv.org/
- GPG signatures of releases made with an expired key HOT 2
- potential perf regeressions due to io_uring `SQPOLL` HOT 3
- test: udp_multicast_join, udp_multicast_join6 failed under loongarch64 HOT 3
- Abstract socket namespace not work for 1.48 HOT 4
- several tests ha failed HOT 4
- unix udp close crash HOT 9
- linux,udp: don't use sendmmsg for single datagrams
- bug in libuv io_uring causes incorrect event reports to epoll and busy loop HOT 14
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from libuv.