LCOV - code coverage report

Current view
top level - src - worker_service.dart
Test
lcov.info
Date
2024-11-13
Legend
Lines
hit
not hit
Branches
taken
not taken
# not executed
HitTotalCoverage
Lines44100.0%
Functions00-
Branches00-
Each row represents a line of source code
LineBranchHitsSource code
1import 'dart:async';
2
3import 'worker/worker.dart';
4import 'worker/worker_request.dart';
5
6typedef WorkerInitializer = FutureOr<WorkerService> Function(
7 WorkerRequest startRequest);
8
9typedef CommandHandler = FutureOr<dynamic> Function(WorkerRequest req);
10
11typedef SquadronCallback = void Function();
12typedef SquadronAsyncCallback = FutureOr<void> Function();
13
14/// Extend this class or implement this interface in your worker service if it needs
15/// to take action when the worker thread is started or stopped.
16mixin ServiceInstaller {
17 /// Squadron will call this method as part of the worker thread initialization.
18 /// It will be called just after the service instance has been constructed. The
19 /// future returned by [Worker.start] will not complete before this method completes
20 /// whether synchronously or asynchronously. If this method throws, the future
21 /// returned by [Worker.start] will complete with an error and the service will not
22 /// be available.
231 FutureOr<void> install() {}
24
25 /// Squadron will call this method as part of the worker thread shutdown process.
26 /// It will be called just before effectively closing the platform channel. If
27 /// this method throws, the exception will not bubble up to the parent thread.
28 /// Also, [Worker.stop] does not wait for this method to complete.
291 FutureOr<void> uninstall() {}
30}
31
32/// Base class for a worker service.
33abstract interface class WorkerService {
34 /// Map of command handlers. Upon reception of a [WorkerRequest], the platform
35 /// worker will dispatch the request to the [CommandHandler] mathing the value
36 /// of [WorkerRequest.command].
37 Map<int, CommandHandler> get operations;
38
39 /// Empty command handlers map.
402 static final Map<int, CommandHandler> noOperations =
411 Map<int, CommandHandler>.unmodifiable(const {});
42}
Choose Features