-
Hey, just getting started with Async Rust and I was hoping I could get some feedback. I'm trying to implement a heartbeat, i.e, run a async function and run something else on an interval while the first one is still in progress. A rough gist of the code I'm attempting is below but my main query is whether running I ask because most examples I've seen of loop+select! are in the main function.
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
select internally builds a |
Beta Was this translation helpful? Give feedback.
select internally builds a
poll_fn(|cx| { /* */ })
which polls each of the futures until one is ready or until all have been polled. it puts a.await
on thepoll_fn
which yields to the executor if all the futures polled inside returned Pending, otherwise it will execute the branch associated with the ready future. You can see the code yourself withcargo-expand