Give `Future`s for a `FutureState` an idx and track `StdWaker` idxn
authorMatt Corallo <git@bluematt.me>
Tue, 13 Feb 2024 22:08:55 +0000 (22:08 +0000)
committerMatt Corallo <git@bluematt.me>
Thu, 15 Feb 2024 21:52:06 +0000 (21:52 +0000)
commit5f404b9d0a0a160aa305b5a9421026e58c7ef609
tree8b7e744666c348429373fb6e1fd1263450a88b11
parent2c987209f9fdeeebd7f2f9f13fd6fee97542ce1b
Give `Future`s for a `FutureState` an idx and track `StdWaker` idxn

When an `std::future::Future` is `poll()`ed, we're only supposed to
use the latest `Waker` provided. However, we currently push an
`StdWaker` onto our callback list every time `poll` is called,
waking every `Waker` but also using more and more memory until the
`Future` itself is woken.

Here we take a step towards fixing this by giving each `Future` a
unique index and storing which `Future` an `StdWaker` came from in
the callback list. This sets us up to deduplicate `StdWaker`s by
`Future`s in the next commit.
lightning/src/util/wakers.rs