Learn R Programming

crew (version 0.5.0)

crew_class_schedule: Schedule class

Description

R6 class to contain and manage task objects.

Arguments

Public fields

seconds_interval

See crew_schedule().

pushed

Hash table of pushed tasks.

collected

Linked list of resolved tasks with results available.

pushes

Number of times a task has been pushed.

head

ID of the task at the head of the collected linked list.

tail

ID of the task at the tail of the collected linked list.

until

Numeric of length 1, time point when throttled task collection unlocks.

Methods


Method new()

Schedule constructor.

Usage

crew_class_schedule$new(seconds_interval = NULL)

Arguments

seconds_interval

See crew_schedule().

Returns

An R6 schedule object.


Method validate()

Validate the schedule.

Usage

crew_class_schedule$validate()

Returns

NULL (invisibly).


Method start()

Start the schedule.

Usage

crew_class_schedule$start()

Details

Sets the pushed and collected hash tables to new empty environments.

Returns

NULL (invisibly).


Method summary()

Summarize the schedule.

Usage

crew_class_schedule$summary()

Returns

NULL if not started. Otherwise, a tibble with the following columns:

  • pushed: number tasks that were pushed but not collected yet. These tasks may or may not have completed.

  • collected: number of tasks that completed and were collected but not yet retrieved with pop().


Method push()

Push a task.

Usage

crew_class_schedule$push(task)

Arguments

task

The mirai task object to push.

Details

Add a task to the pushed hash table

Returns

NULL (invisibly).


Method throttle()

Throttle repeated calls.

Usage

crew_class_schedule$throttle()

Returns

TRUE to throttle, FALSE to continue.


Method collect()

Collect resolved tasks.

Usage

crew_class_schedule$collect(throttle = FALSE)

Arguments

throttle

whether to defer task collection until the next task collection request at least seconds_interval seconds from the original request. The idea is similar to shiny::throttle() except that crew does not accumulate a backlog of requests. The technique improves robustness and efficiency.

Details

Scan the tasks in pushed and move the resolved ones to the head of the collected linked list.

Returns

NULL (invisibly).


Method list()

List collected tasks.

Usage

crew_class_schedule$list()

Details

Exists to support a purrr-like extension to crew for functional programming. For developers only. Not supported for controller groups.

Returns

A list of monad objects from individual tasks.


Method pop()

Pop a task from the collected linked list.

Usage

crew_class_schedule$pop()

Returns

A task object if available, NULL otherwise.


Method empty()

Check if the schedule is empty.

Usage

crew_class_schedule$empty()

Returns

TRUE if the pushed and collected hash tables are both empty, FALSE otherwise.


Method nonempty()

Check if the schedule is nonempty.

Usage

crew_class_schedule$nonempty()

Returns

TRUE if either pushed or collected is nonempty, FALSE otherwise.


Method collected_all()

Check if all previously pushed tasks are now collected.

Usage

crew_class_schedule$collected_all()

Returns

TRUE if all previously pushed tasks are now collected, FALSE otherwise. Could be FALSE if there are unresolved tasks or there are no tasks at all.


Method collected_one()

Check if there is at least one collected task or there are no pushed tasks.

Usage

crew_class_schedule$collected_one()

Returns

TRUE if there is at least one collected task or there are no pushed tasks, FALSE otherwise.


Method collected_mode()

Either collected_all() or collected_one(), depending on the mode argument.

Usage

crew_class_schedule$collected_mode(mode = "all")

Arguments

mode

"all" to call collected_all() or "one" to call collected_one().

Returns

TRUE or FALSE, depending on mode and the state of the schedule.

Details

Not a user-side class. There are no examples. Please see crew_controller_local() for details.

See Also

Other class: crew_class_client, crew_class_controller_group, crew_class_controller, crew_class_launcher, crew_class_tls