FixedRateTimer class
Timer that is triggered in equal time intervals.
It has summetric cross-language implementation and is often used by Pip.Services toolkit to perform periodic processing and cleanup in microservices.
See INotifiable
Example
class MyComponent {
FixedRateTimer timer = FixedRateTimer(() { cleanup }, 60000);
...
Future open(String correlationId) {
...
timer.start();
...
}
Future close(String correlationId) {
...
timer.stop();
...
}
void cleanup() {
...
}
...
}
- Implemented types
Constructors
- FixedRateTimer([dynamic taskOrCallback, int? interval, int? delay])
- Creates new instance of the timer and sets its values.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
close(
String? correlationId) → Future -
Closes the timer.
override
-
getCallback(
) → (dynamic Function()?) - Gets the callback function that is called when this timer is triggered.
-
getDelay(
) → int? - Gets initial delay before the timer is triggered for the first time.
-
getInterval(
) → int? - Gets periodic timer triggering interval.
-
getTask(
) → INotifiable? - Gets the INotifiable object that receives notifications from this timer.
-
isStarted(
) → bool - Checks if the timer is started.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
setCallback(
dynamic value()?) → void - Sets the callback function that is called when this timer is triggered.
-
setDelay(
int? value) → void - Sets initial delay before the timer is triggered for the first time.
-
setInterval(
int? value) → void - Sets periodic timer triggering interval.
-
setTask(
INotifiable value) → void - Sets a new INotifiable object to receive notifications from this timer.
-
start(
) → void - Starts the timer.
-
stop(
) → void - Stops the timer.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited