LCOV - code coverage report

Current view
top level - /src - timeout_token.dart
Test
lcov.info
Date
2022-04-02
Legend
Lines
hit
not hit
Branches
taken
not taken
# not executed
HitTotalCoverage
Lines1010100.0%
Functions00-
Branches00-
Each row represents a line of source code
LineBranchHitsSource code
1import 'dart:async';
2
3import 'cancellable_token.dart';
4import 'squadron_error.dart';
5import 'worker_exception.dart';
6
7/// Time-out cancellation tokens used by callers of worker services. The token is cancelled automatically after
8/// a period of time indicated by [duration] with a countdown starting only when the task is assigned to a
9/// platform worker.
10class TimeOutToken extends CancellableToken {
112 TimeOutToken(this.duration, [String? message]) : super(message);
12
13 /// Throws an exception, time-out tokens may not be cancelled programmatically.
141 @override
152 void cancel() => throw newSquadronError(
161 'TimeOutToken cannot be cancelled programmatically');
17
18 /// Duration of the timeout. The timer is not started before task is scheduled on a platform worker.
19 final Duration duration;
20
21 Timer? _timer;
22
23 /// Called just before processing a [WorkerRequest]. The [onTimeout] callback may not be null, and a timer will be
24 /// started that will automatically cancel this token if processing takes longer than [duration].
251 @override
263 void start() => _timer ??= Timer(
272 duration,
283 () => super.setException(
294 TaskTimeoutException(message: message, duration: duration)));
30
31 /// Returns `true` if the timeout has started, `false` otherwise.
322 bool get started => _timer != null;
33}
Choose Features