Where job expressions are evaluated.
Active bindings
hooksA named list of currently registered callback hooks.
jobThe currently running
job.psThe
ps::ps_handle()object for the background process.stateThe
worker'sstate:'starting','idle','busy', or'stopped'.uidA short string, e.g.
'W11', that uniquely identifies thisworker.tmpThe
worker'stemporary directory.cndThe error that caused the
workerto stop.
Methods
Method new()
Creates a background R process for running jobs.
Usage
worker_class$new(
globals = NULL,
packages = NULL,
namespace = NULL,
init = NULL,
hooks = NULL,
wait = TRUE,
timeout = Inf
)Arguments
globalsA named list of variables that all
<job>$exprs will have access to. Alternatively, an object that can be coerced to a named list withas.list(), e.g. named vector, data.frame, or environment.packagesCharacter vector of package names to load on
workers.namespaceThe name of a package to attach to the
worker'senvironment.initA call or R expression wrapped in curly braces to evaluate on each
workerjust once, immediately after start-up. Will have access to variables defined byglobalsand assets frompackagesandnamespace. Returned value is ignored.hooksA named list of functions to run when the
workerstate changes, of the formhooks = list(idle = function (worker) {...}). Names ofworkerhooks are typicallystarting,idle,busy,stopped, or'*'(duplicates okay). Seevignette('hooks').waitIf
TRUE, blocks until theworkeris 'idle'. IfFALSE, theworkerobject is returned in the 'starting' state.timeoutHow long to wait for the
workerto finish starting (in seconds). IfNA, defaults to theworker_class$new()argument.
Method print()
Print method for a worker.
Method start()
Restarts a stopped worker.
Method stop()
Stops a worker by terminating the background process
and calling <job>$stop(reason) on any jobs currently
assigned to this worker.
Method restart()
Restarts a worker by calling <worker>$stop(reason)
and <worker>$start() in succession.
Arguments
waitIf
TRUE, blocks until theworkeris 'idle'. IfFALSE, theworkerobject is returned in the 'starting' state.timeoutHow long to wait for the
workerto finish starting (in seconds). IfNA, defaults to theworker_class$new()argument.reasonPassed to
<job>$stop()for anyjobscurrently managed by thisworker.clsPassed to
<job>$stop()for anyjobscurrently managed by thisworker.
Method on()
Attach a callback function to execute when the worker
enters state.
Method wait()
Blocks until the worker enters the given state.
