Struct desync::scheduler::Scheduler
[−]
[src]
pub struct Scheduler { /* fields omitted */ }
The scheduler is used to schedule tasks onto a pool of threads
Methods
impl Scheduler
[src]
fn new() -> Scheduler
[src]
Creates a new scheduler
(There's usually only one scheduler)
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)
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)
fn spawn_thread(&self)
[src]
Spawns a thread in this scheduler
fn create_job_queue(&self) -> Arc<JobQueue>
[src]
Creates a new job queue for this scheduler
fn async<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.
fn future<TFn, Item: 'static + Send>(
&self,
queue: &Arc<JobQueue>,
job: TFn
) -> Box<Future<Item = Item, Error = Canceled>> where
TFn: 'static + Send + FnOnce() -> Item,
[src]
&self,
queue: &Arc<JobQueue>,
job: TFn
) -> Box<Future<Item = Item, Error = Canceled>> where
TFn: 'static + Send + FnOnce() -> Item,
Schedules a job to run and returns a future for retrieving the result
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<Future<Item = Res, Error = Error> + 'a> where
TFn: 'static + Send + FnOnce(Result<Item, Error>) -> Result<Res, Error>,
[src]
&self,
queue: &Arc<JobQueue>,
after: Fut,
job: TFn
) -> Box<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
fn suspend(
&self,
queue: &Arc<JobQueue>
) -> Box<Future<Item = (), Error = Canceled>>
[src]
&self,
queue: &Arc<JobQueue>
) -> Box<Future<Item = (), Error = Canceled>>
Requests that a queue be suspended once it has finished all of its active jobs
fn resume(&self, queue: &Arc<JobQueue>)
[src]
Resumes a queue that was previously suspended
fn sync<Result: Send, TFn: Send + FnOnce() -> Result>(
&self,
queue: &Arc<JobQueue>,
job: TFn
) -> Result
[src]
&self,
queue: &Arc<JobQueue>,
job: TFn
) -> Result
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.