[−][src]Struct timely::worker::Worker
A Worker
is the entry point to a timely dataflow computation. It wraps a Allocate
,
and has a list of dataflows that it manages.
Methods
impl<A: Allocate> Worker<A>
[src]
pub fn new(c: A) -> Worker<A>
[src]
Allocates a new Worker
bound to a channel allocator.
pub fn step(&mut self) -> bool
[src]
Performs one step of the computation.
A step gives each dataflow operator a chance to run, and is the main way to ensure that a computation proceeds.
Examples
timely::execute_from_args(::std::env::args(), |worker| { use timely::dataflow::operators::{ToStream, Inspect}; worker.dataflow::<usize,_,_>(|scope| { (0 .. 10) .to_stream(scope) .inspect(|x| println!("{:?}", x)); }); worker.step(); });
pub fn step_or_park(&mut self, duration: Option<Duration>) -> bool
[src]
Performs one step of the computation.
A step gives each dataflow operator a chance to run, and is the main way to ensure that a computation proceeds.
This method takes an optional timeout and may park the thread until
there is work to perform or until this timeout expires. A value of
None
allows the worker to park indefinitely, whereas a value of
Some(Duration::new(0, 0))
will return without parking the thread.
Examples
timely::execute_from_args(::std::env::args(), |worker| { use std::time::Duration; use timely::dataflow::operators::{ToStream, Inspect}; worker.dataflow::<usize,_,_>(|scope| { (0 .. 10) .to_stream(scope) .inspect(|x| println!("{:?}", x)); }); worker.step_or_park(Some(Duration::from_secs(1))); });
pub fn step_while<F: FnMut() -> bool>(&mut self, func: F)
[src]
Calls self.step()
as long as func
evaluates to true.
Examples
timely::execute_from_args(::std::env::args(), |worker| { use timely::dataflow::operators::{ToStream, Inspect, Probe}; let probe = worker.dataflow::<usize,_,_>(|scope| { (0 .. 10) .to_stream(scope) .inspect(|x| println!("{:?}", x)) .probe() }); worker.step_while(|| probe.less_than(&0)); });
pub fn index(&self) -> usize
[src]
The index of the worker out of its peers.
Examples
timely::execute_from_args(::std::env::args(), |worker| { let index = worker.index(); let peers = worker.peers(); let timer = worker.timer(); println!("{:?}\tWorker {} of {}", timer.elapsed(), index, peers); });
pub fn peers(&self) -> usize
[src]
The total number of peer workers.
Examples
timely::execute_from_args(::std::env::args(), |worker| { let index = worker.index(); let peers = worker.peers(); let timer = worker.timer(); println!("{:?}\tWorker {} of {}", timer.elapsed(), index, peers); });
pub fn timer(&self) -> Instant
[src]
A timer started at the initiation of the timely computation.
Examples
timely::execute_from_args(::std::env::args(), |worker| { let index = worker.index(); let peers = worker.peers(); let timer = worker.timer(); println!("{:?}\tWorker {} of {}", timer.elapsed(), index, peers); });
pub fn new_identifier(&mut self) -> usize
[src]
Allocate a new worker-unique identifier.
This method is public, though it is not expected to be widely used outside of the timely dataflow system.
pub fn log_register(&self) -> RefMut<Registry<WorkerIdentifier>>
[src]
Access to named loggers.
Examples
timely::execute_from_args(::std::env::args(), |worker| { worker.log_register() .insert::<timely::logging::TimelyEvent,_>("timely", |time, data| println!("{:?}\t{:?}", time, data) ); });
pub fn dataflow<T, R, F>(&mut self, func: F) -> R where
T: Refines<()>,
F: FnOnce(&mut Child<Self, T>) -> R,
[src]
T: Refines<()>,
F: FnOnce(&mut Child<Self, T>) -> R,
Construct a new dataflow.
Examples
timely::execute_from_args(::std::env::args(), |worker| { // We must supply the timestamp type here, although // it would generally be determined by type inference. worker.dataflow::<usize,_,_>(|scope| { // uses of `scope` to build dataflow }); });
pub fn dataflow_core<T, R, F, V>(
&mut self,
name: &str,
logging: Option<TimelyLogger>,
resources: V,
func: F
) -> R where
T: Refines<()>,
F: FnOnce(&mut V, &mut Child<Self, T>) -> R,
V: Any + 'static,
[src]
&mut self,
name: &str,
logging: Option<TimelyLogger>,
resources: V,
func: F
) -> R where
T: Refines<()>,
F: FnOnce(&mut V, &mut Child<Self, T>) -> R,
V: Any + 'static,
Construct a new dataflow with specific configurations.
This method constructs a new dataflow, using a name, logger, and additional resources specified as argument. The name is cosmetic, the logger is used to handle events generated by the dataflow, and the additional resources are kept alive for as long as the dataflow is alive (use case: shared library bindings).
Examples
timely::execute_from_args(::std::env::args(), |worker| { // We must supply the timestamp type here, although // it would generally be determined by type inference. worker.dataflow_core::<usize,_,_,_>( "dataflow X", // Dataflow name None, // Optional logger 37, // Any resources |resources, scope| { // Closure // uses of `resources`, `scope`to build dataflow } ); });
Trait Implementations
impl<A: Allocate> AsWorker for Worker<A>
[src]
fn index(&self) -> usize
[src]
fn peers(&self) -> usize
[src]
fn allocate<D: Data>(
&mut self,
identifier: usize,
address: &[usize]
) -> (Vec<Box<dyn Push<Message<D>>>>, Box<dyn Pull<Message<D>>>)
[src]
&mut self,
identifier: usize,
address: &[usize]
) -> (Vec<Box<dyn Push<Message<D>>>>, Box<dyn Pull<Message<D>>>)
fn pipeline<T: 'static>(
&mut self,
identifier: usize,
address: &[usize]
) -> (ThreadPusher<Message<T>>, ThreadPuller<Message<T>>)
[src]
&mut self,
identifier: usize,
address: &[usize]
) -> (ThreadPusher<Message<T>>, ThreadPuller<Message<T>>)
fn new_identifier(&mut self) -> usize
[src]
fn log_register(&self) -> RefMut<Registry<WorkerIdentifier>>
[src]
fn logging(&self) -> Option<TimelyLogger>
[src]
impl<A: Allocate> ScopeParent for Worker<A>
[src]
impl<A: Allocate> Scheduler for Worker<A>
[src]
fn activations(&self) -> Rc<RefCell<Activations>>
[src]
fn activator_for(&self, path: &[usize]) -> Activator
[src]
fn sync_activator_for(&self, path: &[usize]) -> SyncActivator
[src]
impl<A: Allocate> Clone for Worker<A>
[src]
fn clone(&self) -> Self
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Auto Trait Implementations
impl<A> !Send for Worker<A>
impl<A> !Sync for Worker<A>
impl<A> Unpin for Worker<A>
impl<A> !UnwindSafe for Worker<A>
impl<A> !RefUnwindSafe for Worker<A>
Blanket Implementations
impl<T> Data for T where
T: 'static + Clone,
[src]
T: 'static + Clone,
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
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>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
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> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,