Learn R Programming

tcltk2 (version 1.1-4)

tclTask: Schedule and manage delayed tasks

Description

Tcl allows fo scheduling execution of code on the next event loop or after a given time (after Tcl command). tclTaskXxx() functions use it to schedule execution of R code with much control from within R (central management of scheduled tasks, possibility to define redoable tasks, use of S3 objects to keep track of tasks information. The tclAfterXxx() functions are low-level access to the Tcl after command.

Usage

# Convenient tclTask objects management
tclTaskSchedule(wait, expr, id = "task#", redo = FALSE)
tclTaskRun(id)
tclTaskGet(id = NULL, all = FALSE)
tclTaskChange(id, expr, wait, redo)
tclTaskDelete(id)

# Low-level Tcl functions
tclAfter(wait, fun)
tclAfterCancel(task)
tclAfterInfo(task = NULL)

Arguments

wait
Time in ms to delay the task (take care: approximative value, depends on when event loops are triggered). Using a value lower or equal to zero, the task is scheduled on the next event loop.
fun
Name of the R function to run (you may not supply arguments to this function, otherwise it is not scheduled properly; take care of scoping, since a copy of the function will be run from within Tcl).
expr
An expression to run after 'wait'.
id
The R identifier of the task to schedule, if this id contains #}, then, it is replaced by next available number, but you cannot schedule more than a thousand tasks with the same name (the system will give up well before, anyway). If N