Team-class: Consumer classes for parallel evaluation

Description Usage Arguments Constructors Methods Internal Class Fields and Methods Author(s) See Also Examples

Description

A Consumer to divide incoming tasks amongst processes for parallel evaluation; not supported on Windows.

Usage

1
Team(FUN, ..., param)

Arguments

FUN

A function of one argument (the input to this consumer), to be applied to each element of the stream. The return value of the function is the value yield'ed.

...

Additional arguments (e.g., verbose, passed to the Consumer constructor.

param

If provided, a ParallelParam instance, such as generated by MulticoreParam().

Constructors

Use Team to construct instances of this class.

When param is missing, Team consults the registry (see register) for a parallel parameter class. If none is found and .Platform$OS.type == "unix", a default MulticoreParam instance is used. An error is signaled on other operating systems (i.e., Windows)

Methods

See Consumer Methods.

Internal Class Fields and Methods

Internal fields of this class are are described with, e.g., getRefClass("MulticoreTeam")$fields.

Internal methods of this class are described with getRefClass("MulticoreTeam")$methods() and getRefClass("MulticoreTeam")$help().

Author(s)

Martin Morgan mtmorgan@fhcrc.org

See Also

ParallelParam for configuring parallel environments. DAGTeam apply functions organized as a directed acyclic graph.

Examples

1
2
3
4
5
6
7
8
if (.Platform$OS.type != "windows") {
    param <- MulticoreParam(size=5)
    team <- Team(function(x) { Sys.sleep(1); mean(x) }, param=param)
    s <- Stream(Seq(to=50, yieldSize=5), team)
    system.time({while(length(y <- yield(s)))
        print(y)
    })  ## about 2 seconds
}

Streamer documentation built on Nov. 8, 2020, 5:53 p.m.