pub struct Scheduler<'state, 'future, State> { /* private fields */ }
Implementations§
source§impl<'state, 'future, State> Scheduler<'state, 'future, State>where
State: Clone + 'state + 'future,
'state: 'future,
impl<'state, 'future, State> Scheduler<'state, 'future, State>where
State: Clone + 'state + 'future,
'state: 'future,
pub const fn not_exists_reactor(&self) -> bool
pub const fn exists_reactor(&self) -> bool
sourcepub fn schedule<F, Fut>(&mut self, f: F)
pub fn schedule<F, Fut>(&mut self, f: F)
Schedule the new [Reactor
].
The reality [Reactor
] is Future
, it is polled once every time Scheduler::run
is called.
§Examples
ⓘ
use flurx::prelude::*;
#[tokio::main]
async fn main(){
let mut scheduler = Scheduler::<usize>::new();
scheduler.schedule(|task|async move{
// (1)
task.will(wait::until(|state: usize|{
state < 2
})).await;
});
// state is 0, (1) returns [`Future::Pending`].
scheduler.run(0).await;
// state is 1, (1) returns [`Future::Pending`].
scheduler.run(1).await;
// state is 2, (1) returns [`Future::Ready(2)`].
scheduler.run(2).await;
}
Trait Implementations§
Auto Trait Implementations§
impl<'state, 'future, State> Freeze for Scheduler<'state, 'future, State>
impl<'state, 'future, State> !RefUnwindSafe for Scheduler<'state, 'future, State>
impl<'state, 'future, State> !Send for Scheduler<'state, 'future, State>
impl<'state, 'future, State> !Sync for Scheduler<'state, 'future, State>
impl<'state, 'future, State> Unpin for Scheduler<'state, 'future, State>where
State: Unpin,
impl<'state, 'future, State> !UnwindSafe for Scheduler<'state, 'future, State>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more