Learn R Programming

crew (version 0.5.0)

crew_class_launcher_local: Local process launcher class

Description

R6 class to launch and manage local process workers.

Arguments

Super class

crew::crew_class_launcher -> crew_class_launcher_local

Methods

Inherited methods


Method launch_worker()

Launch a local process worker which will dial into a socket.

Usage

crew_class_launcher_local$launch_worker(call, name, launcher, worker, instance)

Arguments

call

Character of length 1 with a namespaced call to crew_worker() which will run in the worker and accept tasks.

name

Character of length 1 with an informative worker name.

launcher

Character of length 1, name of the launcher.

worker

Positive integer of length 1, index of the worker. This worker index remains the same even when the current instance of the worker exits and a new instance launches. It is always between 1 and the maximum number of concurrent workers.

instance

Character of length 1 to uniquely identify the current instance of the worker a the index in the launcher.

Details

The call argument is R code that will run to initiate the worker. Together, the launcher, worker, and instance arguments are useful for constructing informative job names.

Returns

A handle object to allow the termination of the worker later on.


Method terminate_worker()

Terminate a local process worker.

Usage

crew_class_launcher_local$terminate_worker(handle)

Arguments

handle

A process handle object previously returned by launch_worker().

Returns

NULL (invisibly).

Details

See crew_launcher_local().

Examples

Run this code
if (identical(Sys.getenv("CREW_EXAMPLES"), "true")) {
client <- crew_client()
client$start()
launcher <- crew_launcher_local(name = client$name)
launcher$start(workers = client$workers)
launcher$launch(index = 1L)
m <- mirai::mirai("result", .compute = client$name)
Sys.sleep(0.25)
m$data
client$terminate()
}

Run the code above in your browser using DataLab