summaryrefslogtreecommitdiff
path: root/crates/tor-rtcompat/src/scheduler.rs
Commit message (Collapse)AuthorAgeFilesLines
* Make daemon tasks self-contained; introduce NetDirProvidereta2022-03-301-0/+6
| | | | | | | | | | | | | | | The various background daemon tasks that `arti-client` used to spawn are now handled inside their respective crates instead, with functions provided to spawn them that return `TaskHandle`s. This required introducing a new trait, `NetDirProvider`, which steals some functionality from the `DirProvider` trait to enable `tor-circmgr` to depend on it (`tor-circmgr` is a dependency of `tor-dirmgr`, so it can't depend on `DirProvider` directly). While we're at it, we also make some of the tasks wait for events from the `NetDirProvider` instead of sleeping, slightly increasing efficiency.
* tor-rtcompat/scheduler: add unit tests, FireIn -> FireAteta2022-03-241-7/+139
| | | | | Addressing review comments: added some unit tests for the new scheduler type, and made FireIn use an Instant instead (making it FireAt).
* Implement a periodic task scheduler, and a basic dormant modeeta2022-03-231-0/+148
This is a revised version of !397; it implements a scheduling system for periodic tasks that can be externally controlled, and then uses the external control aspect to implement a basic dormant mode (#90). More technically, the scheduling system consists of a `Stream` that periodic tasks are expected to embed in a `while` loop or similar, a way for tasks themselves to choose how long to wait until the stream next yields a result, and a handle to control this outside of the task.