Simulation class
One run of an actor system under a seeded scheduler with virtual time. Created by simulate; the test receives it as its argument.
What is simulated:
- Scheduling. One message is handed to one actor at a time, and which actor goes next is drawn from random. Between two deliveries every handler runs until it has to wait.
- Time. Timers,
Future.delayedand timeouts run on a virtual clock that jumps ahead whenever nothing else can happen, so a test that waits an hour finishes at once. Timers due at the same moment fire in random order, interleaved with message deliveries.
What is not: DateTime.now() and Stopwatch read the real clock (restart
budgets do follow virtual time), and
anything outside the isolate (I/O, other isolates) never completes.
Properties
- elapsed → Duration
-
Virtual time since the run started.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- random → Random
-
The source of every random decision in this run. Use it for the test's
own random choices, so that they are replayed along with the seed.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- seed → int
-
The seed this run was started with.
final
- steps → int
-
How many scheduling steps (deliveries and timers) have run.
no setter
- system → LocalActorSystem
-
The simulated actor system. It is shut down when the test returns.
no setter
-
trace
→ List<
String> -
The scheduling decisions so far, one line each.
no setter
Methods
-
addSystem(
[ActorSystemConfig? config]) → LocalActorSystem - Creates another actor system in the same simulation, for tests of several nodes. All systems share the scheduler, the clock and the seed, and all are shut down when the test returns.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
settle(
) → Future< void> - Completes when the system has gone quiet: no actor has a message it can handle and no timer is due at the current virtual time. Timers set for later do not count, and time does not advance.
-
toString(
) → String -
A string representation of this object.
inherited
-
wait(
Duration duration) → Future< void> -
Completes after
durationof virtual time.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited