pub struct Scheduler { /* private fields */ }
Expand description
The scheduler is used to schedule tasks onto a pool of threads
Implementations
sourceimpl Scheduler
impl Scheduler
sourcepub fn set_max_threads(&self, max_threads: usize)
pub fn set_max_threads(&self, max_threads: usize)
Changes the maximum number of threads this scheduler can spawn (existing threads are not despawned by this method)
sourcepub fn despawn_threads_if_overloaded(&self)
pub fn despawn_threads_if_overloaded(&self)
Despawns threads if we’re running more than the maximum number
Must not be called from a scheduler thread (as it waits for the threads to despawn)
sourcepub fn spawn_thread(&self)
pub fn spawn_thread(&self)
Spawns a thread in this scheduler
sourcepub fn create_job_queue(&self) -> Arc<JobQueue>
pub fn create_job_queue(&self) -> Arc<JobQueue>
Creates a new job queue for this scheduler
sourcepub fn async<TFn: 'static + Send + FnOnce()>(
&self,
queue: &Arc<JobQueue>,
job: TFn
)
pub fn async<TFn: 'static + Send + FnOnce()>(
&self,
queue: &Arc<JobQueue>,
job: TFn
)
Schedules a job on this scheduler, which will run after any jobs that are already in the specified queue and as soon as a thread is available to run it.
sourcepub fn future<TFn, Item: 'static + Send>(
&self,
queue: &Arc<JobQueue>,
job: TFn
) -> Box<dyn Future<Item = Item, Error = Canceled>>where
TFn: 'static + Send + FnOnce() -> Item,
pub fn future<TFn, Item: 'static + Send>(
&self,
queue: &Arc<JobQueue>,
job: TFn
) -> Box<dyn Future<Item = Item, Error = Canceled>>where
TFn: 'static + Send + FnOnce() -> Item,
Schedules a job to run and returns a future for retrieving the result
sourcepub fn after<'a, TFn, Item: 'static + Send, Error: 'static + Send, Res: 'static + Send, Fut: 'a + Future<Item = Item, Error = Error>>(
&self,
queue: &Arc<JobQueue>,
after: Fut,
job: TFn
) -> Box<dyn Future<Item = Res, Error = Error> + 'a>where
TFn: 'static + Send + FnOnce(Result<Item, Error>) -> Result<Res, Error>,
pub fn after<'a, TFn, Item: 'static + Send, Error: 'static + Send, Res: 'static + Send, Fut: 'a + Future<Item = Item, Error = Error>>(
&self,
queue: &Arc<JobQueue>,
after: Fut,
job: TFn
) -> Box<dyn Future<Item = Res, Error = Error> + 'a>where
TFn: 'static + Send + FnOnce(Result<Item, Error>) -> Result<Res, Error>,
Pauses a queue until a particular future has completed, before performing a task with the result of that future
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Scheduler
impl Send for Scheduler
impl Sync for Scheduler
impl Unpin for Scheduler
impl UnwindSafe for Scheduler
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more