Skip to main content

dope_core/driver/ops/poll/
mod.rs

1use std::{io, time};
2
3use crate::driver::schedule;
4
5mod backend;
6mod dispatch;
7mod source;
8
9pub(crate) use backend::Backend;
10pub use dispatch::Dispatch;
11pub use source::Source;
12
13#[derive(Clone, Copy, Debug, Eq, PartialEq)]
14#[must_use = "pending backend events must be drained before blocking"]
15pub enum Drain {
16    /// The backend's visible event queue was empty after synchronization.
17    Drained,
18    /// Visible events remain and require another reactor turn.
19    Pending,
20}
21
22#[derive(Clone, Copy, Debug, Eq, PartialEq)]
23#[must_use = "pending backend changes must be committed in a later reactor turn"]
24pub enum Commit {
25    /// Every change queued before this call has reached the backend.
26    Drained,
27    /// Queued changes remain and require another reactor turn.
28    Pending,
29}
30
31pub trait Poll<'d>: Backend {
32    fn commit(&mut self, work: schedule::Reactor<'_, 'd>) -> io::Result<Commit>;
33
34    fn wait(
35        &mut self,
36        work: schedule::Reactor<'_, 'd>,
37        timeout: Option<time::Duration>,
38    ) -> io::Result<()>;
39}