LCOV - code coverage report

Current view
top level - src - channel.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 'package:logger/web.dart';
4
5import '_impl/xplat/_channel.dart'
6 if (dart.library.io) '_impl/native/_channel.dart'
7 if (dart.library.html) '_impl/web/_channel.dart'
8 if (dart.library.js_interop) '_impl/web/_channel.dart' as impl;
9import 'exceptions/exception_manager.dart';
10import 'tokens/_squadron_cancelation_token.dart';
11import 'typedefs.dart';
12import 'worker/worker_request.dart';
13import 'worker/worker_response.dart';
14
15/// A [Channel] supports communication from a client to a platform worker. It
16/// is used to send a [WorkerRequest] to a platform worker.
17abstract interface class Channel {
18 /// The [ExceptionManager] attached to this channel.
19 ExceptionManager get exceptionManager;
20
21 /// The [Logger] attached to this channel.
22 Logger? get logger;
23
24 /// [Channel] serialization. Returns an opaque object that can be transfered
25 /// from the client to the worker.
26 PlatformChannel serialize();
27
28 /// [Channel] sharing. Returns a [Channel] object that can be provided to
29 /// enable another worker to call the channel's worker.
30 Channel share();
31
32 /// Sends a termination [WorkerRequest] to the worker. The [Channel] should
33 /// release any resource related to the worker and should not be used after
34 /// this method has been called.
35 FutureOr<void> close();
36
37 /// Sends a close stream [WorkerRequest] to the worker.
38 FutureOr<void> cancelStream(int streamId);
39
40 /// Sends a cancel token [WorkerRequest] to the worker.
41 FutureOr<void> cancelToken(SquadronCancelationToken? token);
42
43 /// Creates a [WorkerRequest] and sends it to the worker. This method expects
44 /// a single value from the worker.
45 Future<dynamic> sendRequest(int command, List args,
46 {SquadronCancelationToken? token,
47 bool inspectRequest = false,
48 bool inspectResponse = false});
49
50 /// Creates a [WorkerRequest] and sends it to the worker. This method expects
51 /// a stream of values from the worker. The worker must send a
52 /// [WorkerResponse.closeStream] message to close the [Stream].
53 Stream<dynamic> sendStreamingRequest(int command, List args,
54 {SquadronCancelationToken? token,
55 bool inspectRequest = false,
56 bool inspectResponse = false});
57
58 /// Starts a worker using the [entryPoint] and sends a start [WorkerRequest]
59 /// with [startArguments]. The future must not complete before the worker is
60 /// ready to serve requests.
6110 static Future<Channel> open(ExceptionManager exceptionManager, Logger? logger,
62 EntryPoint entryPoint, List startArguments,
63 [PlatformThreadHook? hook]) =>
6420 impl.openChannel(
65 entryPoint, exceptionManager, logger, startArguments, hook);
66
67 /// Deserializes a [Channel] from an opaque [channelInfo].
683 static Channel? deserialize(PlatformChannel? channelInfo,
69 [Logger? logger, ExceptionManager? exceptionManager]) =>
703 impl.deserialize(channelInfo, logger, exceptionManager);
71}
Choose Features