runWithToken method
Runs task providing a ZenithCancellationToken that is cancelled when
this scope is disposed.
Implementation
void runWithToken(Future<void> Function(ZenithCancellationToken token) task) {
if (_isDisposed || _isClosing) return;
final token = ZenithCancellationToken();
_activeTokens.add(token);
Future.sync(() => task(token)).whenComplete(() {
_activeTokens.remove(token);
});
}