LCOV - code coverage report

Current view
top level - /src - _pool_worker.dart
Test
lcov.info
Date
2022-04-02
Legend
Lines
hit
not hit
Branches
taken
not taken
# not executed
HitTotalCoverage
Lines2222100.0%
Functions00-
Branches00-
Each row represents a line of source code
LineBranchHitsSource code
1part of 'worker_pool.dart';
2
3class _PoolWorker<W extends Worker> {
42 _PoolWorker(this.worker, this._maxWorkload) : _capacity = _maxWorkload;
5
6 final W worker;
7
8 final int _maxWorkload;
9 int? _lastStart;
10 int _capacity;
11
123 int get capacity => _capacity;
137 bool get isIdle => worker.isStopped || _capacity == _maxWorkload;
14
151 void _start() {
164 _lastStart = DateTime.now().millisecondsSinceEpoch;
172 _capacity--;
18 }
19
202 void _finish() {
212 _capacity++;
224 if (_capacity == _maxWorkload) {
232 _lastStart = null;
24 }
251 }
26
271 Future run(WorkerTask task) {
281 _start();
295 return task.run(worker).whenComplete(_finish);
30 }
31
322 static int compareCapacityDesc(_PoolWorker a, _PoolWorker b) {
337 if (a.capacity != b.capacity) return b.capacity.compareTo(a.capacity);
342 if (a._lastStart == null) return 1;
352 if (b._lastStart == null) return -1;
364 return a._lastStart!.compareTo(b._lastStart!);
371 }
38
394 static bool isStopped(_PoolWorker w) => w.worker.isStopped;
404 static WorkerStat getStats(_PoolWorker w) => w.worker.stats;
41}
Choose Features