timely/scheduling/
mod.rs

1//! Types and traits to activate and schedule fibers.
2
3use std::rc::Rc;
4use std::cell::RefCell;
5
6pub mod activate;
7
8pub use self::activate::{Activations, Activator, ActivateOnDrop, SyncActivator};
9
10/// A type that can be scheduled.
11pub trait Schedule {
12    /// A descriptive name for the operator
13    fn name(&self) -> &str;
14    /// An address identifying the operator.
15    fn path(&self) -> &[usize];
16    /// Schedules the operator, receives "cannot terminate" boolean.
17    ///
18    /// The return value indicates whether `self` has outstanding
19    /// work and would be upset if the computation terminated.
20    fn schedule(&mut self) -> bool;
21}
22
23/// Methods for types which schedule fibers.
24pub trait Scheduler {
25    /// Provides a shared handle to the activation scheduler.
26    fn activations(&self) -> Rc<RefCell<Activations>>;
27
28    /// Constructs an `Activator` tied to the specified operator address.
29    fn activator_for(&self, path: Rc<[usize]>) -> Activator {
30        Activator::new(path, self.activations())
31    }
32
33    /// Constructs a `SyncActivator` tied to the specified operator address.
34    fn sync_activator_for(&self, path: Vec<usize>) -> SyncActivator {
35        let sync_activations = self.activations().borrow().sync();
36        SyncActivator::new(path, sync_activations)
37    }
38}