LCOV - code coverage report

Current view
top level - /src - local_worker.dart
Test
lcov.info
Date
2022-04-02
Legend
Lines
hit
not hit
Branches
taken
not taken
# not executed
HitTotalCoverage
Lines33100.0%
Functions00-
Branches00-
Each row represents a line of source code
LineBranchHitsSource code
1import '_local_worker_stub.dart'
2 if (dart.library.js) 'browser/_local_worker.dart'
3 if (dart.library.html) 'browser/_local_worker.dart'
4 if (dart.library.io) 'native/_local_worker.dart';
5
6import 'channel.dart';
7import 'worker_request.dart';
8import 'worker_service.dart';
9
10/// Base local worker class.
11///
12/// Local workers are similar to other Workers except that they run in the context of the current thread.
13/// They do not create any platform thread (such as Isolate or Web Worker) but they provide a [channel] that
14/// can be shared with other workers to support communication between threads. One interesting use-case is
15/// accessing UI components or platform plugins in Flutter, where only code running in the main thread is
16/// allowed access to such features. Creating a [LocalWorker] in the main application and sharing its
17/// [channel] with other workers enables providing access to Flutter features.
18///
19/// Local workers wrap around a [WorkerService]. Messages sent to the local worker are deserialized as
20/// [WorkerRequest] and dispatched to a handler defined in the [service]'s [WorkerService.operations] map
21/// according to the [WorkerRequest.command].
22abstract class LocalWorker<W extends WorkerService> implements WorkerService {
231 LocalWorker(this.service);
24
252 factory LocalWorker.create(W service) => createLocalWorker<W>(service);
26
27 /// The [WorkerService] associated to this local worker.
28 final W service;
29
30 /// The local worker's [Channel]. This channel can be shared with other workers by calling [Channel.share].
31 Channel? get channel;
32
33 /// Stops the local worker.
34 void stop();
35
36 /// Local Workers do not need an [operations] map.
37 @override
381 final Map<int, CommandHandler> operations = WorkerService.noOperations;
39}
Choose Features