The R Project SVN R

Rev

Rev 29362 | Rev 50821 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 29362 Rev 30915
Line 83... Line 83...
83
  \code{\link{getTaskCallbackNames}}
83
  \code{\link{getTaskCallbackNames}}
84
  \code{\link{taskCallbackManager}}
84
  \code{\link{taskCallbackManager}}
85
  \url{http://developer.r-project.org/TaskHandlers.pdf}
85
  \url{http://developer.r-project.org/TaskHandlers.pdf}
86
}
86
}
87
\examples{
87
\examples{
88
  times <- function(total = 3, str="Task a") {
88
 times <- function(total = 3, str="Task a") {
89
    ctr <- 0
89
   ctr <- 0
90
 
90
 
91
    function(expr, value, ok, visible) {
91
   function(expr, value, ok, visible) {
92
     ctr <<- ctr + 1
92
    ctr <<- ctr + 1
93
     cat(str, ctr, "\n")
93
    cat(str, ctr, "\n")
94
     if(ctr == total) {
94
    if(ctr == total) {
95
       cat("handler removing itself\n")
95
      cat("handler removing itself\n")
96
     }
-
 
97
     return(ctr < total)
-
 
98
    }
96
    }
-
 
97
    return(ctr < total)
99
  }
98
   }
-
 
99
 }
100
 
100
 
101
  # add the callback that will work for
101
 # add the callback that will work for
102
  # 4 top-level tasks and then remove itself.
102
 # 4 top-level tasks and then remove itself.
103
  n <- addTaskCallback(times(4))
103
 n <- addTaskCallback(times(4))
104
 
104
 
105
  # now remove it, assuming it is still first in the list.
105
 # now remove it, assuming it is still first in the list.
106
  removeTaskCallback(n)
106
 removeTaskCallback(n)
107
 
107
 
108
\dontrun{
108
\dontrun{
109
 # There is no point in running this
109
# There is no point in running this
110
 # as 
110
# as 
111
  addTaskCallback(times(4))
111
 addTaskCallback(times(4))
112
 
112
 
113
  sum(1:10)
113
 sum(1:10)
114
  sum(1:10)
114
 sum(1:10)
115
  sum(1:10)
115
 sum(1:10)
116
  sum(1:10)
116
 sum(1:10)
117
  sum(1:10)
117
 sum(1:10)
118
}
118
}
119
}
119
}
120
\keyword{environment}
120
\keyword{environment}