everywhere: Evaluate Everywhere

View source: R/mirai.R

everywhereR Documentation

Evaluate Everywhere

Description

Evaluate an expression 'everywhere' on all connected daemons for the specified compute profile. Designed for performing setup operations across daemons, resultant changes to the global environment, loaded packages or options are persisted regardless of a daemon's 'cleanup' setting.

Usage

everywhere(.expr, ..., .args = list(), .compute = "default")

Arguments

.expr

an expression to evaluate asynchronously (of arbitrary length, wrapped in {} if necessary), or a language object passed by name.

...

(optional) named arguments (name = value pairs) specifying objects referenced in '.expr'. Used in addition to, and taking precedence over, any arguments specified via '.args'.

.args

(optional) either a list of objects to be passed by name (found in the current scope), or else a list of name = value pairs, as in '...'.

.compute

[default 'default'] character value for the compute profile to use when sending the mirai.

Value

Invisible NULL.

Examples

if (interactive()) {
# Only run examples in interactive R sessions

daemons(1)
everywhere(list2env(x, envir = .GlobalEnv), x = list(a = 1, b = 2))
m <- mirai(a + b)
call_mirai(m)$data
daemons(0)

daemons(1, dispatcher = FALSE)
everywhere(library(parallel))
m <- mirai("package:parallel" %in% search())
call_mirai(m)$data
daemons(0)

}


mirai documentation built on Nov. 16, 2023, 5:08 p.m.