3 ms·
To answer one question: > I find surprising that you need to reference count a task explicitly. This is likely due to how the task and waker system is defined
by Matthias247 7y ago
To answer one question:
> I find surprising that you need to reference count a task explicitly.
This is likely due to how the task and waker system is defined in Rust. A Waker is kind of a handle to the task, whose lifetime is indefinite. Some code can have a handle/Waker to a task which already has finished long ago. One way to make sure the handle is still valid is to reference count it. Since in the Tokio system the Waker/handle and the tasks internal state are actually the same object, this means the combined state gets a reference count.