async: move timer out of async engine
This commit is contained in:
parent
dcdd91c0b0
commit
4d8a340cd0
6 changed files with 86 additions and 76 deletions
|
|
@ -1,19 +1,17 @@
|
|||
mod ae_fd;
|
||||
mod ae_queue;
|
||||
mod ae_task;
|
||||
mod ae_timer;
|
||||
mod ae_yield;
|
||||
|
||||
pub use {
|
||||
crate::async_engine::ae_yield::Yield,
|
||||
ae_fd::{AsyncFd, FdStatus},
|
||||
ae_task::SpawnedFuture,
|
||||
ae_timer::Timer,
|
||||
};
|
||||
use {
|
||||
crate::{
|
||||
event_loop::{EventLoop, EventLoopError},
|
||||
utils::{copyhashmap::CopyHashMap, numcell::NumCell, oserror::OsError},
|
||||
utils::{copyhashmap::CopyHashMap, numcell::NumCell},
|
||||
},
|
||||
ae_fd::AsyncFdData,
|
||||
ae_queue::{DispatchQueue, Dispatcher},
|
||||
|
|
@ -23,19 +21,13 @@ use {
|
|||
rc::Rc,
|
||||
},
|
||||
thiserror::Error,
|
||||
uapi::{c, OwnedFd},
|
||||
uapi::OwnedFd,
|
||||
};
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum AsyncError {
|
||||
#[error("The event loop caused an error")]
|
||||
EventLoopError(#[from] EventLoopError),
|
||||
#[error("Could not read from a timer")]
|
||||
TimerReadError(#[source] OsError),
|
||||
#[error("Could not set a timer")]
|
||||
SetTimer(#[source] OsError),
|
||||
#[error("Could not create a timer")]
|
||||
CreateTimer(#[source] OsError),
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Eq, PartialEq)]
|
||||
|
|
@ -63,10 +55,6 @@ impl AsyncEngine {
|
|||
}))
|
||||
}
|
||||
|
||||
pub fn timer(self: &Rc<Self>, clock_id: c::c_int) -> Result<Timer, AsyncError> {
|
||||
Timer::new(self, clock_id)
|
||||
}
|
||||
|
||||
pub fn clear(&self) {
|
||||
for (_, fd) in self.fds.lock().drain() {
|
||||
fd.readers.take();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue