waitThread -
a class that encapsulates a timed action.
A task can be programmed to be performed after
a fixed interval and optionally repeated
any number of times every n seconds.
This is similar to the sleep function, but
the task is evaluated asynchronously so the calling
function returns immediately and does not wait for the
action to complete or for the duration of the delay.
new("waitThread")
# print a running count, starting at 1,
# on the standard output connection every minute.
waitThread(interval=60, Quote(print(i = i + 1)), data=list(i=1),repeat=T)
# print a running count 10 times - 1 per minute
waitThread(interval=rep(60,10),
Quote(print(i = i + 1)), data=list(i=1),repeat=T)
# print a running count.
# the first after 1 second, the next 2 seconds later
# the next 4 seconds later, etc.
waitThread(interval=2^(0:9),
Quote(print(i = i + 1)), data=list(i=1),repeat=T)