Skip to contents

R6 class for sequential controllers.

See also

Other sequential controllers: crew_controller_sequential()

Super class

crew::crew_class_controller -> crew_class_controller_sequential

Methods

Inherited methods


Method start()

Start the controller if it is not already started.

Usage

crew_class_controller_sequential$start(controllers = NULL)

Arguments

controllers

Not used. Included to ensure the signature is compatible with the analogous method of controller groups.

Details

For the sequential controller, there is nothing to do except register the client as started.

Returns

NULL (invisibly).


Method launch()

Does nothing for the sequential controller.

Usage

crew_class_controller_sequential$launch(n = 1L, controllers = NULL)

Arguments

n

Number of workers to launch.

controllers

Not used. Included to ensure the signature is compatible with the analogous method of controller groups.

Returns

NULL (invisibly).


Method scale()

Does nothing for the sequential controller.

Usage

crew_class_controller_sequential$scale(throttle = TRUE, controllers = NULL)

Arguments

throttle

Not applicable to the sequential controller.

controllers

Not used. Included to ensure the signature is compatible with the analogous method of controller groups.

Returns

Invisibly returns FALSE.


Method autoscale()

Not applicable to the sequential controller.

Usage

crew_class_controller_sequential$autoscale(controllers = NULL)

Arguments

controllers

Not used. Included to ensure the signature is compatible with the analogous method of controller groups.

Returns

NULL (invisibly).


Method descale()

Not applicable to the sequential controller.

Usage

crew_class_controller_sequential$descale(controllers = NULL)

Arguments

controllers

Not used. Included to ensure the signature is compatible with the analogous method of controller groups.

Returns

NULL (invisibly).


Method push()

Push a task to the head of the task list.

Usage

crew_class_controller_sequential$push(
  command,
  data = list(),
  globals = list(),
  substitute = TRUE,
  seed = NULL,
  algorithm = NULL,
  packages = character(0),
  library = NULL,
  seconds_timeout = NULL,
  scale = TRUE,
  throttle = TRUE,
  name = NULL,
  save_command = NULL,
  controller = NULL
)

Arguments

command

Language object with R code to run.

data

Named list of local data objects in the evaluation environment.

globals

Named list of objects to temporarily assign to the global environment for the task. This list should include any functions you previously defined in the global environment which are required to run tasks. See the reset_globals argument of crew_controller_local().

substitute

Logical of length 1, whether to call base::substitute() on the supplied value of the command argument. If TRUE (default) then command is quoted literally as you write it, e.g. push(command = your_function_call()). If FALSE, then crew assumes command is a language object and you are passing its value, e.g. push(command = quote(your_function_call())). substitute = TRUE is appropriate for interactive use, whereas substitute = FALSE is meant for automated R programs that invoke crew controllers.

seed

Integer of length 1 with the pseudo-random number generator seed to set for the evaluation of the task. Passed to the seed argument of set.seed() if not NULL. If algorithm and seed are both NULL for the sequential controller, then the random number generator defaults to the current RNG of the local R session where the sequential controller lives.

algorithm

Integer of length 1 with the pseudo-random number generator algorithm to set for the evaluation of the task. Passed to the kind argument of RNGkind() if not NULL. If algorithm and seed are both NULL for the sequential controller, then the random number generator defaults to the current RNG of the local R session where the sequential controller lives.

packages

Character vector of packages to load for the task.

library

Library path to load the packages. See the lib.loc argument of require().

seconds_timeout

Not used in the sequential controller..

scale

Not used in the sequential controller.

throttle

Not used in the sequential controller.

name

Character string, name of the task. If NULL, then a random name is generated automatically. The name of the task must not conflict with the name of another task pushed to the controller. Any previous task with the same name must first be popped before a new task with that name can be pushed.

save_command

Deprecated on 2025-01-22 (crew version 0.10.2.9004) and no longer used.

controller

Not used. Included to ensure the signature is compatible with the analogous method of controller groups.

Returns

Invisibly returns a mirai-like list where the data element is the result of the task.


Method wait()

Not applicable to the sequential controller.

Usage

crew_class_controller_sequential$wait(
  mode = "all",
  seconds_interval = NULL,
  seconds_timeout = Inf,
  scale = TRUE,
  throttle = TRUE,
  controllers = NULL
)

Arguments

mode

Not applicable to the sequential controller.

seconds_interval

Not applicable to the sequential controller.

seconds_timeout

Not applicable to the sequential controller.

scale

Not applicable to the sequential controller.

throttle

Not applicable to the sequential controller.

controllers

Not used. Included to ensure the signature is compatible with the analogous method of controller groups.

Returns

Always returns TRUE (invisibly) for the sequential controller.


Method push_backlog()

Not applicable to the sequential controller.

Usage

crew_class_controller_sequential$push_backlog(name, controller = NULL)

Arguments

name

Character of length 1 with the task name to push to the backlog.

controller

Not used. Included to ensure the signature is compatible with the analogous method of controller groups.

Returns

NULL (invisibly).


Method pop_backlog()

Not applicable to the sequential controller.

Usage

crew_class_controller_sequential$pop_backlog(controllers = NULL)

Arguments

controllers

Not used. Included to ensure the signature is compatible with the analogous method of controller groups.

Returns

Always character(0L) for the sequential controller.


Method cancel()

Not applicable to the sequential controller.

Usage

crew_class_controller_sequential$cancel(names = character(0L), all = FALSE)

Arguments

names

Not applicable to the sequential controller.

all

Not applicable to the sequential controller.

Examples

if (identical(Sys.getenv("CREW_EXAMPLES"), "true")) {
controller <- crew_controller_sequential()
controller$push(name = "task", command = sqrt(4))
controller$pop()
}