crew_class_throttle {crew} | R Documentation |
R6
throttle class.
Description
R6
class for throttle configuration.
Details
See crew_throttle()
.
Active bindings
seconds_max
See
crew_throttle()
.seconds_min
See
crew_throttle()
.seconds_start
See
crew_throttle()
.base
See
crew_throttle()
.seconds_interval
Current wait time interval.
polled
Positive numeric of length 1, millisecond timestamp of the last time
poll()
returnedTRUE
.NULL
ifpoll()
was never called on the current object.
Methods
Public methods
Method new()
Throttle constructor.
Usage
crew_class_throttle$new( seconds_max = NULL, seconds_min = NULL, seconds_start = NULL, base = NULL )
Arguments
seconds_max
See
crew_throttle()
.seconds_min
See
crew_throttle()
.seconds_start
See
crew_throttle()
.base
See
crew_throttle()
.
Returns
An R6
object with throttle configuration.
Examples
throttle <- crew_throttle(seconds_max = 1) throttle$poll() throttle$poll()
Method validate()
Validate the object.
Usage
crew_class_throttle$validate()
Returns
NULL
(invisibly).
Method poll()
Poll the throttler.
Usage
crew_class_throttle$poll()
Returns
TRUE
if poll()
did not return TRUE
in the last
max
seconds, FALSE
otherwise.
Method accelerate()
Divide seconds_interval
by base
.
Usage
crew_class_throttle$accelerate()
Returns
NULL
(invisibly). Called for its side effects.
Method decelerate()
Multiply seconds_interval
by base
.
Usage
crew_class_throttle$decelerate()
Returns
NULL
(invisibly). Called for its side effects.
Method reset()
Reset the throttle object so the next poll()
returns
TRUE
, and reset the wait time interval to its initial value.
Usage
crew_class_throttle$reset()
Returns
NULL
(invisibly).
Method update()
Reset the throttle when there is activity and decelerate it gradually when there is no activity.
Usage
crew_class_throttle$update(activity)
Arguments
activity
TRUE
if there is activity,FALSE
otherwise.
Returns
NULL
(invisibly).
See Also
Other throttle:
crew_throttle()
Examples
throttle <- crew_throttle(seconds_max = 1)
throttle$poll()
throttle$poll()
## ------------------------------------------------
## Method `crew_class_throttle$new`
## ------------------------------------------------
throttle <- crew_throttle(seconds_max = 1)
throttle$poll()
throttle$poll()