Struct timely_util::Worker

source ·
pub struct Worker<A>where
    A: Allocate,
{ /* private fields */ }
Expand description

A Worker is the entry point to a timely dataflow computation. It wraps a Allocate, and has a list of dataflows that it manages.

Implementations§

Allocates a new Worker bound to a channel allocator.

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();
});

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)));
});

Calls self.step() as long as func evaluates to true.

This method will continually execute even if there is not work for the worker to perform. Consider using the similar method Self::step_or_park_while(duration) to allow the worker to yield control if that is appropriate.

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));
});

Calls self.step_or_park(duration) as long as func evaluates to true.

This method may yield whenever there is no work to perform, as performed by Self::step_or_park(). Please consult the documentation for further information about that method and its behavior. In particular, the method can park the worker indefinitely, if no new work re-awakens the worker.

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_or_park_while(None, || probe.less_than(&0));
});

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);

});

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);

});

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);

});

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.

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)
          );
});

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

    });
});

Construct a new dataflow with a (purely cosmetic) name.

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_named::<usize,_,_>("Some Dataflow", |scope| {

        // uses of `scope` to build dataflow

    });
});

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

        }
    );
});

Drops an identified dataflow.

This method removes the identified dataflow, which will no longer be scheduled. Various other resources will be cleaned up, though the method is currently in public beta rather than expected to work. Please report all crashes and unmet expectations!

Returns the next index to be used for dataflow construction.

This identifier will appear in the address of contained operators, and can be used to drop the dataflow using self.drop_dataflow().

List the current dataflow indices.

Trait Implementations§

Returns the worker configuration parameters.
Index of the worker among its peers.
Number of peer workers.
Allocates a new channel from a supplied identifier and address. Read more
Constructs a pipeline channel from the worker to itself. Read more
Allocates a new worker-unique identifier.
Provides access to named logging streams.
Provides access to the timely logging stream.
Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Provides a shared handle to the activation scheduler.
Constructs an Activator tied to the specified operator address.
Constructs a SyncActivator tied to the specified operator address.
The timestamp associated with data in this scope.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.