Comments (4)
UPDATE: Never mind. The reason I was seeing blocking is because I had a background task spinning on a future that always returned an error so it never yielded. So not relevant to the above & still confused by the note.
Ok, I am seeing scenarios where the Timer never returns if I await a tokio oneshot receiver and attach an .or with a timer to that future:
let (_tx, rx) = tokio::oneshot::channel();
rx.or(async move {
glommio::sleep(Duration::from_millis(30));
}).await // Deadlock!!!
The timeout code does work if I use glommio::timeout so I suspect this deadlock is what the Timer docs refer to. What's confusing is that on the front page of the docs the example has:
let timeout = async {
Timer::new(Duration::from_secs(10)).await;
Err(io::Error::new(io::ErrorKind::TimedOut, "").into())
};
let stream = TcpStream::connect("::80").or(timeout).await?;
which would then seem like an erroneous example to have without the warning / an explanation of why this example might work but others following the same pattern won't in other cases (or maybe the example itself doesn't work which would be even worse).
from glommio.
@glommer if you get a chance I'd love to understand what the warning means if you remember.
from glommio.
The wording there is not the best, since it doesn't really block it.
What it means is that given Rust's concurrency model, calling .await
will - as you put it - delay the current task.
I think I still had the seastar model in my mind when I wrote that code, in which a future starts executing immediately when you call it, and in my mind this behavior was "blocking"-like (but hey, it's been a while)
from glommio.
Ok. I'll put up a PR to clear up the wording.
from glommio.
Related Issues (20)
- Ordering of `ReadManyResult ` HOT 2
- process gets stuck in D state if there is a big read (about 6 MB) HOT 4
- Document what happens on non-Linux+io-uring-support HOT 3
- RawTask memory leak HOT 5
- `Directory::open` fails consistently where `std::fs::` succeeds
- Support for sending raw Ethernet frames HOT 3
- this is no core_cpus_list file, how to fix it?
- What's the problem with performance, implementation or usage? HOT 6
- Is it possible to make a release? HOT 3
- Harden read buffer pool HOT 2
- RFC: A Send safe `DmaFile` to let the fd be shared across threads
- Valgrind complains about uninitialized memory in buffer returned by read_at_aligned
- Statx is invoked on path instead of fd
- RFC: 0-copy support for writing reads HOT 2
- Can't build an application that using Glommio HOT 5
- Timer adds a surprising amount of delay vs thread::sleep HOT 3
- Any interest in adding advisory lock support?
- Implement `Send + Sync` for `ReadResult` HOT 2
- OS/kernel version recommendation HOT 2
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 glommio.