| timer_check {governor} | R Documentation |
Check the status of a timer
Description
Check the status of a timer
Usage
timer_check(timer)
Arguments
timer |
timer object returned by |
Value
logical indicating if timer was triggered. If TRUE, then
the internal state of the timer will be reset (so that it will
trigger again after another duraction has elapsed)
Examples
# Run two timers in a tight while loop
# The short timer should trigger every 0.1 seconds
# The long timer will trigger after 1 second
# Note that the timers will reset every time they trigger (after returning TRUE)
long_timer <- timer_init(1)
short_timer <- timer_init(0.1)
counter <- 0L
while(TRUE) {
if (timer_check(long_timer)) {
cat("\nLong timer fired at count: ", counter, "\n")
break;
}
if (timer_check(short_timer)) {
cat("Short timer fired at count: ", counter, "\n")
}
counter <- counter + 1L
}
[Package governor version 0.1.2 Index]