Description
Isolate.addOnExitListener
allows the owner of an isolate to listen for that isolate terminating. However, this notion of termination doesn't match the notion the VM uses to determine when a Dart application should exit. When running an application directly, the VM will exit once there are no more events scheduled on the event loop, no more timers running, no open ReceivePort
s, and no external streams or futures that may fire. Being able to emulate that behavior is important when using isolates to run Dart scripts.
One possible solution would be to add something like Isolate.addOnDoneListener
, which would fire using the same criteria as the VM. Another solution which is probably too radical would be to have isolates automatically terminate if they have no more work to do.
This is blocking dart-lang/pub#1204.