[][src]Struct desync::scheduler::Scheduler

pub struct Scheduler { /* fields omitted */ }

The scheduler is used to schedule tasks onto a pool of threads

Methods

impl Scheduler[src]

pub fn new() -> Scheduler[src]

Creates a new scheduler

(There's usually only one scheduler)

pub fn set_max_threads(&self, max_threads: usize)[src]

Changes the maximum number of threads this scheduler can spawn (existing threads are not despawned by this method)

pub fn despawn_threads_if_overloaded(&self)[src]

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)

pub fn spawn_thread(&self)[src]

Spawns a thread in this scheduler

pub fn create_job_queue(&self) -> Arc<JobQueue>[src]

Creates a new job queue for this scheduler

pub fn async<TFn: 'static + Send + FnOnce()>(
    &self,
    queue: &Arc<JobQueue>,
    job: TFn
)
[src]

Deprecated since 0.3.0:

please use desync instead

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.

pub fn desync<TFn: 'static + Send + FnOnce()>(
    &self,
    queue: &Arc<JobQueue>,
    job: TFn
)
[src]

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.

pub fn future<TFn, TFuture>(
    &self,
    queue: &Arc<JobQueue>,
    job: TFn
) -> impl Future<Output = Result<TFuture::Output, Canceled>> + Send where
    TFn: 'static + Send + FnOnce() -> TFuture,
    TFuture: 'static + Send + Future,
    TFuture::Output: Send
[src]

Schedules a job to run and returns a future for retrieving the result

pub fn after<TFn, Res: 'static + Send, Fut: 'static + Future + Send>(
    &self,
    queue: &Arc<JobQueue>,
    after: Fut,
    job: TFn
) -> impl Future<Output = Result<Res, Canceled>> + Send where
    TFn: 'static + Send + FnOnce(Fut::Output) -> Res, 
[src]

Pauses a queue until a particular future has completed, before performing a task with the result of that future

pub fn suspend(
    &self,
    queue: &Arc<JobQueue>
) -> impl Future<Output = Result<QueueResumer, Canceled>> + Send
[src]

Requests that a queue be suspended once it has finished all of its active jobs

pub fn sync<Result: Send, TFn: Send + FnOnce() -> Result>(
    &self,
    queue: &Arc<JobQueue>,
    job: TFn
) -> Result
[src]

Schedules a job on this scheduler, which will run after any jobs that are already in the specified queue. This function will not return until the job has completed.

Trait Implementations

impl Debug for Scheduler[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.