Skip to content

Draft: Implement a periodic task scheduler, and use it in arti-client

eta requested to merge eta/arti:task-scheduler into main

[this is currently draft code, and lots of things, particularly error handling and documentation, are deliberately omitted. I'm mainly interested in feedback on the shape of this as a whole]

This implements a generic task scheduler in tor_rtcompat::scheduler (maybe it should have its own crate?), capable of running tasks (functions that return a pinned, boxed future) at regular intervals (defined by the return value of the task function).

It also implements functionality to suspend and reschedule running tasks. This isn't used in this commit yet, but is a useful API to reduce unnecessary wakeups: for example, the timeout testing loop could mark itself suspended when it's collected enough samples, and be unsuspended by another piece of code when it should run again. (#180 (closed))

Having everything in one scheduler will also make the "dormant mode" support (#90) a lot easier to implement: the scheduler could simply just stop running tasks when commanded.

Merge request reports

Loading