[][src]Struct timely::worker::Worker

pub struct Worker<A: Allocate> { /* fields omitted */ }

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_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]

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]

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 logging(&self) -> Option<TimelyLogger>[src]

Provides access to the timely logging stream.

impl<A: Allocate> ScopeParent for Worker<A>[src]

type Timestamp = ()

The timestamp associated with data in this scope.

impl<A: Allocate> Scheduler for Worker<A>[src]

fn activator_for(&self, path: &[usize]) -> Activator[src]

impl<A: Allocate> Clone for Worker<A>[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

Auto Trait Implementations

impl<A> !Send for Worker<A>

impl<A> !Sync for Worker<A>

Blanket Implementations

impl<T> Data for T where
    T: 'static + Clone
[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]