Movatterモバイル変換


[0]ホーム

URL:


taskCallbackManager {base}R Documentation

Create an R-level Task Callback Manager

Description

This provides an entirelyR-language mechanismfor managing callbacks or actions that are invoked atthe conclusion of each top-level task. Essentially,we register a singleR function from this managerwith the underlying, nativetask-callback mechanism and this function handles invoking the otherR callbacks under the control of the manager.The manager consists of a collection of functions that access sharedvariables to manage the list of user-level callbacks.

Usage

taskCallbackManager(handlers = list(), registered = FALSE,                    verbose = FALSE)

Arguments

handlers

this can be a list of callbacks in which each elementis a list with an element named"f"which is a callback function, and an optionalelement named"data" which is the 5-th argument to besupplied to the callback when it is invoked.Typically this argument is not specified, and one usesadd toregister callbacks after the manager is created.

registered

a logical value indicating whethertheevaluate function has already been registeredwith the internal task callback mechanism.This is usuallyFALSE andthe first time a callback is addedvia theadd function, theevaluate function is automatically registered.One can control when the function is registeredby specifyingTRUE for this argumentand callingaddTaskCallback manually.

verbose

a logical value, which ifTRUE,causes information to be printed to the consoleabout certain activities this dispatch manager performs.This is useful for debugging callbacks and the handleritself.

Value

Alist containing 6 functions:

add()

register a callback with this manager, giving thefunction, an optional 5-th argument, an optional nameby which the callback is stored in the list,and aregister argument which controls whethertheevaluate function is registered with the internalC-level dispatch mechanism if necessary.

remove()

remove an element from the manager's collectionof callbacks, either by name or position/index.

evaluate()

the ‘real’ callback function that is registeredwith the C-level dispatch mechanism and which invokes each of theR-level callbacks within this manager's control.

suspend()

a function to set the suspend stateof the manager. If it is suspended, none of the callbacks will beinvoked when a task is completed. One sets the state by specifyinga logical value for thestatus argument.

register()

a function to register theevaluatefunction with the internal C-level dispatch mechanism. This isdone automatically by theadd function, but can be calledmanually.

callbacks()

returns the list of callbacks being maintainedby this manager.

References

Temple Lang D (2001).“Top-level Task Callbacks in R.”https://developer.r-project.org/TaskHandlers.pdf.

See Also

addTaskCallback,removeTaskCallback,getTaskCallbackNames and the reference.

Examples

# create the managerh <- taskCallbackManager()# add a callbackh$add(function(expr, value, ok, visible) {                       cat("In handler\n")                       return(TRUE)                     }, name = "simpleHandler")# look at the internal callbacks.getTaskCallbackNames()# look at the R-level callbacksnames(h$callbacks())removeTaskCallback("R-taskCallbackManager")

[Packagebase version 4.6.0Index]

[8]ページ先頭

©2009-2025 Movatter.jp