5 ms·
I don’t fully understand your use case, but in case this helps: - Future is a trait, not a type, so you can write your own future types. - Future’s poll metho
by comex 7y ago
I don’t fully understand your use case, but in case this helps:
- Future is a trait, not a type, so you can write your own future types.
- Future’s poll method takes a context argument, and async/await-based futures pass that argument unchanged to any sub-futures that they await. The context argument is a pointer to a standard library type (std::task::Context), which itself contains a pointer to a “waker” object that’s meant to be supplied by the executor, with some predefined methods. There’s some room for customization here, but it’s not as flexible as it probably should be – e.g. for now, as far as I can tell, you can’t get the pointer back out of the waker, only call the standard methods on it. Thread-local storage is an option, of course.