[−][src]Struct desync::scheduler::Scheduler
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]
&self,
queue: &Arc<JobQueue>,
job: TFn
)
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]
&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.
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]
&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,
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]
&self,
queue: &Arc<JobQueue>,
after: Fut,
job: TFn
) -> impl Future<Output = Result<Res, Canceled>> + Send where
TFn: 'static + Send + FnOnce(Fut::Output) -> Res,
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]
&self,
queue: &Arc<JobQueue>
) -> impl Future<Output = Result<QueueResumer, Canceled>> + Send
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]
&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.
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
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,