use futures::future::BoxFuture;
use futures::stream::BoxStream;
use crate::file::{IoRequest, ReadSourceRef};
mod blocking;
pub use blocking::*;
mod handle;
pub use handle::*;
#[cfg(not(target_arch = "wasm32"))]
pub mod current;
#[cfg(not(target_arch = "wasm32"))]
mod pool;
#[cfg(not(target_arch = "wasm32"))]
pub mod single;
#[cfg(not(target_arch = "wasm32"))]
mod smol;
#[cfg(feature = "tokio")]
pub mod tokio;
#[cfg(target_arch = "wasm32")]
pub mod wasm;
#[cfg(test)]
mod tests;
pub(crate) trait Executor: Send + Sync {
fn spawn(&self, fut: BoxFuture<'static, ()>) -> AbortHandleRef;
fn spawn_cpu(&self, task: Box<dyn FnOnce() + Send + 'static>) -> AbortHandleRef;
fn spawn_blocking(&self, task: Box<dyn FnOnce() + Send + 'static>) -> AbortHandleRef;
fn spawn_io(&self, task: IoTask);
}
pub(crate) trait AbortHandle: Send + Sync {
fn abort(self: Box<Self>);
}
pub(crate) type AbortHandleRef = Box<dyn AbortHandle>;
pub(crate) struct IoTask {
pub(crate) source: ReadSourceRef,
pub(crate) stream: BoxStream<'static, IoRequest>,
}
impl IoTask {
pub(crate) fn new(source: ReadSourceRef, stream: BoxStream<'static, IoRequest>) -> Self {
IoTask { source, stream }
}
}