CreateTask: CreateTask

View source: R/CreateTask.R

CreateTaskR Documentation

CreateTask

Description

Create a long-running task, on Linux executed in a forked process, on Windows in the same session.

Usage

CreateTask(expr, args = NULL, timeout = 1000L)

Arguments

expr

Expression to be executed. Required.

args

List object with arguments to be passed to expr. Optional. Default = NULL

timeout

Number of milliseconds between consecutive checks of the task. Optional. Default = 1000L

Details

The return value is a promise-like object with three methods:
- completed(): FALSE initially, then TRUE if the task succeeds, fails, or is cancelled. Reactive, so when the state changes any reactive readers will invalidate.
- result(): Use this to get the return value. While execution is in progress, performs a req(FALSE). If task succeeded, returns the return value. If failed, throws error. Reactive, so when the state changes any reactive readers will invalidate.
- cancel(): Call this to prematurely terminate the task.

Value

Closure

Examples

## Not run: 
task <- CreateTask({
  Sys.sleep(5)
  cars[sample(nrow(cars), 10),]
})
shiny::isolate(task$result())

## End(Not run)


nextpagesoft/hivEstimatesAccuracy documentation built on Sept. 17, 2024, 5 a.m.