taskCallbackManager(base)
taskCallbackManager()所属R语言包:base
Create an R-level Task Callback Manager
创建一个R级的任务回调经理
译者:生物统计家园网 机器人LoveR
描述----------Description----------
This provides an entirely S-language mechanism for managing callbacks or actions that are invoked at the conclusion of each top-level task. Essentially, we register a single R function from this manager with the underlying, native task-callback mechanism and this function handles invoking the other R callbacks under the control of the manager. The manager consists of a collection of functions that access shared variables to manage the list of user-level callbacks.
这提供了一个管理行动,在每个顶层的任务结束时调用回调或完全的S-语言机制。从本质上讲,我们注册这个经理从底层,原生的任务回调机制和处理经理的控制下调用其他R回调此功能单一的R函数。经理由访问共享变量的功能来管理用户级别的回调列表的集合。
用法----------Usage----------
taskCallbackManager(handlers = list(), registered = FALSE,
verbose = FALSE)
参数----------Arguments----------
参数:handlers
this can be a list of callbacks in which each element is a list with an element named "f" which is a callback function, and an optional element named "data" which is the 5-th argument to be supplied to the callback when it is invoked. Typically this argument is not specified, and one uses add to register callbacks after the manager is created.
这可以是一个回调的名单,其中每个元素是一个命名元素的列表"f"这是一个回调函数,和一个可选的元素名为"data"这是5个参数,将提供给当它被调用的回调。通常,这种说法是没有指定,使用add注册回调后,经理创建。
参数:registered
a logical value indicating whether the evaluate function has already been registered with the internal task callback mechanism. This is usually FALSE and the first time a callback is added via the add function, the evaluate function is automatically registered. One can control when the function is registered by specifying TRUE for this argument and calling addTaskCallback manually.
一个逻辑值,指明是否evaluate函数内部的任务回调机制已经注册。这通常是FALSE并在第一时间通过add函数添加回调,evaluate功能会自动注册。一个可以控制函数时指定TRUE这种说法,并呼吁addTaskCallback手动注册。
参数:verbose
a logical value, which if TRUE, causes information to be printed to the console about certain activities this dispatch manager performs. This is useful for debugging callbacks and the handler itself.
一个逻辑值,如果TRUE,导致信息被打印到控制台这个调度经理执行某些活动。这是有用的调试回调和处理程序本身。
值----------Value----------
A list containing 6 functions:
一个列表,其中包含6个功能:
参数:add
register a callback with this manager, giving the function, an optional 5-th argument, an optional name by which the callback is stored in the list, and a register argument which controls whether the evaluate function is registered with the internal C-level dispatch mechanism if necessary.
注册一个回调,这个经理给功能,可选5个参数,回调存储在列表中的一个可选的名字,和register参数控制是否evaluate函数注册与C级,如果有必要的内部调度机制。
参数:remove
remove an element from the manager's collection of callbacks, either by name or position/index.
从经理的回调集合中删除一个元素,通过名称或位置/指数。
参数:evaluate
the "real" callback function that is registered with the C-level dispatch mechanism and which invokes each of the R-level callbacks within this manager's control.
真正的与C级的调度机制和注册的回调函数调用每个经理的控制范围内的R级别的回调。
参数:suspend
a function to set the suspend state of the manager. If it is suspended, none of the callbacks will be invoked when a task is completed. One sets the state by specifying a logical value for the status argument.
一个函数来设置经理挂起状态。被暂停,如果没有回调会被调用时,任务完成。一个由国家指定为status论点的逻辑值设置。
参数:register
a function to register the evaluate function with the internal C-level dispatch mechanism. This is done automatically by the add function, but can be called manually.
一个函数来注册的evaluate函数与内部C级调度机制。这是由add功能自动完成,但可以手动调用。
参数:callbacks
returns the list of callbacks being maintained by this manager.
返回保持这个经理的回调列表。
参见----------See Also----------
addTaskCallback, removeTaskCallback, getTaskCallbackNames\ http://developer.r-project.org/TaskHandlers.pdf
addTaskCallback,removeTaskCallback,getTaskCallbackNames \ http://developer.r-project.org/TaskHandlers.pdf
举例----------Examples----------
# create the manager[创建经理]
h <- taskCallbackManager()
# add a callback[添加一个回调]
h$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 callbacks[看的R级回调]
names(h$callbacks())
getTaskCallbackNames()
removeTaskCallback("R-taskCallbackManager")
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|