From ea4dcbf7b8679b99f435d4aab98ca32c728f3887 Mon Sep 17 00:00:00 2001 From: d-markey Date: Sun, 20 Oct 2024 00:59:08 +0000 Subject: [PATCH] Automated test coverage report --- coverage.json | 2 +- doc/coverage/html/index.html | 24 +- .../_impl/native/_bootstrapper.dart.gcov.html | 2 +- .../src/_impl/native/_channel.dart.gcov.html | 304 ++--- .../_impl/native/_channel_impl.dart.gcov.html | 2 +- .../_impl/native/_local_worker.dart.gcov.html | 2 +- .../src/_impl/native/_platform.dart.gcov.html | 2 +- .../src/_impl/native/_typedefs.dart.gcov.html | 2 +- .../native/_worker_channel.dart.gcov.html | 6 +- .../native/_worker_runner.dart.gcov.html | 2 +- doc/coverage/html/src/_impl/native/index.html | 10 +- .../src/_impl/web/_channel.dart.gcov.html | 427 +++---- .../_impl/web/_channel_impl.dart.gcov.html | 14 +- .../_impl/web/_entry_point_uri.dart.gcov.html | 2 +- .../_impl/web/_event_buffer.dart.gcov.html | 4 +- .../_impl/web/_local_worker.dart.gcov.html | 2 +- .../html/src/_impl/web/_patch.dart.gcov.html | 10 +- .../src/_impl/web/_platform.dart.gcov.html | 2 +- .../src/_impl/web/_typedefs.dart.gcov.html | 2 +- .../src/_impl/web/_uri_checker.dart.gcov.html | 2 +- .../_impl/web/_worker_channel.dart.gcov.html | 2 +- .../_impl/web/_worker_runner.dart.gcov.html | 2 +- doc/coverage/html/src/_impl/web/index.html | 10 +- .../_disconnected_channel.dart.gcov.html | 2 +- .../xplat/_forward_completer.dart.gcov.html | 2 +- .../_forward_stream_controller.dart.gcov.html | 12 +- .../xplat/_internal_logger.dart.gcov.html | 2 +- .../_impl/xplat/_result_stream.dart.gcov.html | 22 +- .../_impl/xplat/_time_stamp.dart.gcov.html | 2 +- .../src/_impl/xplat/_token_id.dart.gcov.html | 2 +- .../_impl/xplat/_transferables.dart.gcov.html | 2 +- .../_impl/xplat/_worker_runner.dart.gcov.html | 1031 +++++++++-------- doc/coverage/html/src/_impl/xplat/index.html | 10 +- doc/coverage/html/src/annotations/index.html | 14 +- .../squadron_method.dart.gcov.html | 2 +- .../squadron_service.dart.gcov.html | 107 +- .../target_platform.dart.gcov.html | 118 ++ .../html/src/bootstrapper.dart.gcov.html | 2 +- doc/coverage/html/src/channel.dart.gcov.html | 2 +- .../src/concurrency_settings.dart.gcov.html | 2 +- .../converters/cast_converter.dart.gcov.html | 2 +- .../src/converters/converter.dart.gcov.html | 2 +- .../direct_cast_converter.dart.gcov.html | 2 +- .../in_place_converter.dart.gcov.html | 2 +- doc/coverage/html/src/converters/index.html | 2 +- .../lazy_in_place_converter.dart.gcov.html | 2 +- .../lazy_in_place_list.dart.gcov.html | 2 +- .../lazy_in_place_map.dart.gcov.html | 2 +- .../converters/num_converter.dart.gcov.html | 2 +- .../_well_known_exceptions.dart.gcov.html | 2 +- .../exception_manager.dart.gcov.html | 10 +- doc/coverage/html/src/exceptions/index.html | 2 +- ...squadron_canceled_exception.dart.gcov.html | 2 +- ...quadron_canceled_exceptions.dart.gcov.html | 2 +- .../exceptions/squadron_error.dart.gcov.html | 4 +- .../squadron_exception.dart.gcov.html | 14 +- .../squadron_timeout_exception.dart.gcov.html | 2 +- .../task_canceled_exception.dart.gcov.html | 2 +- .../worker_exception.dart.gcov.html | 2 +- doc/coverage/html/src/index.html | 2 +- doc/coverage/html/src/local_worker/index.html | 10 +- .../local_worker/local_worker.dart.gcov.html | 18 +- .../local_worker_client.dart.gcov.html | 4 +- .../generic_marshaler.dart.gcov.html | 2 +- .../identity_marshaler.dart.gcov.html | 2 +- doc/coverage/html/src/marshalers/index.html | 2 +- .../squadron_marshaler.dart.gcov.html | 2 +- .../html/src/pool/_pool_worker.dart.gcov.html | 2 +- .../pool/_worker_stream_task.dart.gcov.html | 8 +- .../html/src/pool/_worker_task.dart.gcov.html | 2 +- .../pool/_worker_value_task.dart.gcov.html | 2 +- doc/coverage/html/src/pool/index.html | 2 +- .../html/src/pool/worker_pool.dart.gcov.html | 2 +- .../src/squadron_platform_type.dart.gcov.html | 2 +- .../src/squadron_singleton.dart.gcov.html | 2 +- doc/coverage/html/src/stats/index.html | 2 +- .../src/stats/perf_counter.dart.gcov.html | 2 +- .../perf_counter_snapshot.dart.gcov.html | 2 +- .../html/src/stats/worker_stat.dart.gcov.html | 2 +- .../_cancelation_token_ref.dart.gcov.html | 2 +- ..._squadron_cancelation_token.dart.gcov.html | 2 +- doc/coverage/html/src/tokens/index.html | 2 +- doc/coverage/html/src/typedefs.dart.gcov.html | 2 +- doc/coverage/html/src/worker/index.html | 2 +- .../html/src/worker/worker.dart.gcov.html | 2 +- .../src/worker/worker_channel.dart.gcov.html | 2 +- .../src/worker/worker_message.dart.gcov.html | 8 +- .../src/worker/worker_request.dart.gcov.html | 2 +- .../src/worker/worker_response.dart.gcov.html | 40 +- .../html/src/worker_service.dart.gcov.html | 6 +- doc/coverage/xml/index.xml | 12 +- .../_impl/native/_bootstrapper.dart.gcov.xml | 2 +- .../src/_impl/native/_channel.dart.gcov.xml | 221 ++-- .../_impl/native/_channel_impl.dart.gcov.xml | 2 +- .../_impl/native/_local_worker.dart.gcov.xml | 2 +- .../src/_impl/native/_platform.dart.gcov.xml | 2 +- .../src/_impl/native/_typedefs.dart.gcov.xml | 2 +- .../native/_worker_channel.dart.gcov.xml | 10 +- .../_impl/native/_worker_runner.dart.gcov.xml | 2 +- doc/coverage/xml/src/_impl/native/index.xml | 6 +- .../xml/src/_impl/web/_channel.dart.gcov.xml | 315 ++--- .../src/_impl/web/_channel_impl.dart.gcov.xml | 26 +- .../_impl/web/_entry_point_uri.dart.gcov.xml | 2 +- .../src/_impl/web/_event_buffer.dart.gcov.xml | 6 +- .../src/_impl/web/_local_worker.dart.gcov.xml | 2 +- .../xml/src/_impl/web/_patch.dart.gcov.xml | 18 +- .../xml/src/_impl/web/_platform.dart.gcov.xml | 2 +- .../xml/src/_impl/web/_typedefs.dart.gcov.xml | 2 +- .../src/_impl/web/_uri_checker.dart.gcov.xml | 2 +- .../_impl/web/_worker_channel.dart.gcov.xml | 2 +- .../_impl/web/_worker_runner.dart.gcov.xml | 2 +- doc/coverage/xml/src/_impl/web/index.xml | 6 +- .../xplat/_disconnected_channel.dart.gcov.xml | 2 +- .../xplat/_forward_completer.dart.gcov.xml | 2 +- .../_forward_stream_controller.dart.gcov.xml | 22 +- .../xplat/_internal_logger.dart.gcov.xml | 2 +- .../_impl/xplat/_result_stream.dart.gcov.xml | 42 +- .../src/_impl/xplat/_time_stamp.dart.gcov.xml | 2 +- .../src/_impl/xplat/_token_id.dart.gcov.xml | 2 +- .../_impl/xplat/_transferables.dart.gcov.xml | 2 +- .../_impl/xplat/_worker_runner.dart.gcov.xml | 809 +++++++------ doc/coverage/xml/src/_impl/xplat/index.xml | 6 +- doc/coverage/xml/src/annotations/index.xml | 7 +- .../annotations/squadron_method.dart.gcov.xml | 2 +- .../squadron_service.dart.gcov.xml | 104 +- .../annotations/target_platform.dart.gcov.xml | 50 + .../xml/src/bootstrapper.dart.gcov.xml | 2 +- doc/coverage/xml/src/channel.dart.gcov.xml | 2 +- .../src/concurrency_settings.dart.gcov.xml | 2 +- .../converters/cast_converter.dart.gcov.xml | 2 +- .../src/converters/converter.dart.gcov.xml | 2 +- .../direct_cast_converter.dart.gcov.xml | 2 +- .../in_place_converter.dart.gcov.xml | 2 +- doc/coverage/xml/src/converters/index.xml | 8 +- .../lazy_in_place_converter.dart.gcov.xml | 2 +- .../lazy_in_place_list.dart.gcov.xml | 2 +- .../lazy_in_place_map.dart.gcov.xml | 2 +- .../converters/num_converter.dart.gcov.xml | 2 +- .../_well_known_exceptions.dart.gcov.xml | 2 +- .../exception_manager.dart.gcov.xml | 18 +- doc/coverage/xml/src/exceptions/index.xml | 2 +- .../squadron_canceled_exception.dart.gcov.xml | 2 +- ...squadron_canceled_exceptions.dart.gcov.xml | 2 +- .../exceptions/squadron_error.dart.gcov.xml | 6 +- .../squadron_exception.dart.gcov.xml | 26 +- .../squadron_timeout_exception.dart.gcov.xml | 2 +- .../task_canceled_exception.dart.gcov.xml | 2 +- .../exceptions/worker_exception.dart.gcov.xml | 2 +- doc/coverage/xml/src/index.xml | 2 +- doc/coverage/xml/src/local_worker/index.xml | 6 +- .../local_worker/local_worker.dart.gcov.xml | 19 +- .../local_worker_client.dart.gcov.xml | 4 +- .../generic_marshaler.dart.gcov.xml | 2 +- .../identity_marshaler.dart.gcov.xml | 2 +- doc/coverage/xml/src/marshalers/index.xml | 2 +- .../squadron_marshaler.dart.gcov.xml | 2 +- .../xml/src/pool/_pool_worker.dart.gcov.xml | 2 +- .../pool/_worker_stream_task.dart.gcov.xml | 14 +- .../xml/src/pool/_worker_task.dart.gcov.xml | 2 +- .../src/pool/_worker_value_task.dart.gcov.xml | 2 +- doc/coverage/xml/src/pool/index.xml | 2 +- .../xml/src/pool/worker_pool.dart.gcov.xml | 2 +- .../src/squadron_platform_type.dart.gcov.xml | 2 +- .../xml/src/squadron_singleton.dart.gcov.xml | 2 +- doc/coverage/xml/src/stats/index.xml | 2 +- .../xml/src/stats/perf_counter.dart.gcov.xml | 2 +- .../stats/perf_counter_snapshot.dart.gcov.xml | 2 +- .../xml/src/stats/worker_stat.dart.gcov.xml | 2 +- .../_cancelation_token_ref.dart.gcov.xml | 2 +- .../_squadron_cancelation_token.dart.gcov.xml | 2 +- doc/coverage/xml/src/tokens/index.xml | 2 +- doc/coverage/xml/src/typedefs.dart.gcov.xml | 2 +- doc/coverage/xml/src/worker/index.xml | 2 +- .../xml/src/worker/worker.dart.gcov.xml | 2 +- .../src/worker/worker_channel.dart.gcov.xml | 2 +- .../src/worker/worker_message.dart.gcov.xml | 14 +- .../src/worker/worker_request.dart.gcov.xml | 2 +- .../src/worker/worker_response.dart.gcov.xml | 78 +- .../xml/src/worker_service.dart.gcov.xml | 10 +- 179 files changed, 2429 insertions(+), 1931 deletions(-) create mode 100644 doc/coverage/html/src/annotations/target_platform.dart.gcov.html create mode 100644 doc/coverage/xml/src/annotations/target_platform.dart.gcov.xml diff --git a/coverage.json b/coverage.json index c8b55633..81f68202 100644 --- a/coverage.json +++ b/coverage.json @@ -1 +1 @@ -{"linesValid":2321,"lineRate":87.3} \ No newline at end of file +{"linesValid":2351,"lineRate":87.3} \ No newline at end of file diff --git a/doc/coverage/html/index.html b/doc/coverage/html/index.html index 47cb5487..1e4436e2 100644 --- a/doc/coverage/html/index.html +++ b/doc/coverage/html/index.html @@ -16,7 +16,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
@@ -37,7 +37,7 @@

LCOV - code coverage report

- Lines2027232187.3% + Lines2052235187.3% Functions00- @@ -66,23 +66,23 @@

LCOV - code coverage report

src/_impl/native - 90.2% - 90.2%148/164-0/0-0/0 + 90.5% + 90.5%153/169-0/0-0/0 src/_impl/web - 81.8% - 81.8%256/313-0/0-0/0 + 82.1% + 82.1%262/319-0/0-0/0 src/_impl/xplat - 78.3% - 78.3%275/351-0/0-0/0 + 78.0% + 78.0%287/368-0/0-0/0 src/annotations - 11.1% - 11.1%1/9-0/0-0/0 + 20.0% + 20.0%2/10-0/0-0/0 src/converters @@ -96,8 +96,8 @@

LCOV - code coverage report

src/local_worker - 65.2% - 65.2%15/23-0/0-0/0 + 66.7% + 66.7%16/24-0/0-0/0 src/marshalers diff --git a/doc/coverage/html/src/_impl/native/_bootstrapper.dart.gcov.html b/doc/coverage/html/src/_impl/native/_bootstrapper.dart.gcov.html index 6d27840e..3d110b15 100644 --- a/doc/coverage/html/src/_impl/native/_bootstrapper.dart.gcov.html +++ b/doc/coverage/html/src/_impl/native/_bootstrapper.dart.gcov.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
diff --git a/doc/coverage/html/src/_impl/native/_channel.dart.gcov.html b/doc/coverage/html/src/_impl/native/_channel.dart.gcov.html index ac686f6f..b3d4b078 100644 --- a/doc/coverage/html/src/_impl/native/_channel.dart.gcov.html +++ b/doc/coverage/html/src/_impl/native/_channel.dart.gcov.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
@@ -40,7 +40,7 @@

LCOV - code coverage report

- Lines415082.0% + Lines465583.6% Functions00- @@ -169,295 +169,313 @@

LCOV - code coverage report

3610 final completer = Completer<Channel>(); - 37 + 37 Channel? channel; - - 3810 void failure(Object error, [StackTrace? stackTrace]) { + + 38 - 3910 if (!completer.isCompleted) { + 3910 void failure(Object error, [StackTrace? stackTrace]) { - 406 completer.completeError(SquadronException.from(error, stackTrace)); + 4010 if (!completer.isCompleted) { - - 41 } + + 416 completer.completeError(SquadronException.from(error, stackTrace)); - 42 } + 42 } - 43 + 43 } - - 449 void success(Channel channel) { + + 44 - 459 if (!completer.isCompleted) { + 459 void success(Channel channel) { - 469 completer.complete(channel); + 469 if (!completer.isCompleted) { - - 47 } + + 479 completer.complete(channel); - 48 } + 48 } - 49 + 49 } - - 5010 final receiver = vm.ReceivePort(); + + 50 - 5110 final exitPort = vm.ReceivePort(); + 5110 final receiver = vm.ReceivePort(); - 5210 final errorPort = vm.ReceivePort(); + 5210 final exitPort = vm.ReceivePort(); - - 53 + + 5310 final errorPort = vm.ReceivePort(); - - 5420 exitPort.listen((message) { + + 54 - 5520 failure(SquadronErrorExt.create('Connection to worker failed')); + 5520 exitPort.listen((message) { - 562 logger?.t('Isolate terminated.'); + 5620 failure(SquadronErrorExt.create('Connection to worker failed')); - 5710 receiver.close(); + 572 logger?.t('Isolate terminated.'); - 5810 errorPort.close(); + 589 channel?.close(); - 5910 exitPort.close(); + 5910 receiver.close(); - - 60 }); + + 6010 errorPort.close(); - - 61 + + 6110 exitPort.close(); - - 6210 errorPort.listen((message) { + + 62 }); - 63 SquadronException? error; + 63 - - 64 try { + + 6410 errorPort.listen((message) { - - 650 final data = jsonDecode(message[0]); + + 65 SquadronException? error; - - 660 if (data is List) { + + 66 try { - 670 error = exceptionManager.deserialize(data.cast<String>()); + 670 final data = jsonDecode(message[0]); - - 68 } + + 680 if (data is List) { - - 69 } catch (_) { + + 690 error = exceptionManager.deserialize(data.cast<String>()); - 70 // not a String representing a SquadronException + 70 } - 71 } + 71 } catch (_) { - 72 + 72 // not a String representing a SquadronException - - 730 error ??= WorkerException( + + 73 } - - 740 message[0], + + 74 - 750 SquadronException.loadStackTrace(message[1]), + 750 error ??= WorkerException( - - 76 ); + + 760 message[0], - - 77 + + 770 SquadronException.loadStackTrace(message[1]), - - 780 logger?.d(() => 'Unhandled error from Isolate: ${error?.message}.'); + + 78 ); - - 790 failure(error); + + 79 - - 80 }); + + 800 logger?.d(() => 'Unhandled error from Isolate: ${error?.message}.'); - - 81 + + 810 failure(error); - - 8210 final disconnected = DisconnectedChannel(exceptionManager, logger); + + 82 }); 83 - 8419 receiver.listen((message) { + 8410 final disconnected = DisconnectedChannel(exceptionManager, logger); - - 859 final response = WorkerResponseExt.from(message); + + 85 - 869 if (!response.unwrapInPlace(disconnected)) { + 8619 receiver.listen((message) { - - 87 return; + + 879 final response = WorkerResponseExt.from(message); - - 88 } + + 889 if (!response.unwrapInPlace(disconnected)) { - 89 + 89 return; - - 909 final error = response.error; + + 90 } - 91 if (error != null) { + 91 - 924 logger?.e(() => 'Connection to Isolate failed: ${response.error}'); + 929 final error = response.error; - - 932 failure(error); + + 93 if (error != null) { - 949 } else if (!completer.isCompleted) { + 944 logger?.e(() => 'Connection to Isolate failed: ${response.error}'); - 952 logger?.t('Connected to Isolate'); + 952 failure(error); - 9627 success(_VmChannel._(response.result, logger, exceptionManager)); + 969 } else if (response.endOfStream) { - - 97 } else { + + 971 logger?.w('Disconnecting from Isolate'); - - 980 logger?.e(() => 'Unexpected response: $response'); + + 981 channel?.close(); - - 99 } + + 999 } else if (!completer.isCompleted) { - - 100 }); + + 1002 logger?.t('Connected to Isolate'); - - 101 + + 10118 channel = _VmChannel._(response.result, logger, exceptionManager); - 10220 final startRequest = WorkerRequest.start(receiver.sendPort, startArguments); + 1029 success(channel!); - - 10310 startRequest.wrapInPlace(); + + 103 } else { - - 10410 final isolate = await vm.Isolate.spawn( + + 1040 logger?.e(() => 'Unexpected response: $response'); - 105 entryPoint, + 105 } - 106 startRequest, + 106 }); - 107 errorsAreFatal: false, + 107 - 10810 onExit: exitPort.sendPort, + 10820 final startRequest = WorkerRequest.start(receiver.sendPort, startArguments); - 10910 onError: errorPort.sendPort, + 10910 startRequest.wrapInPlace(); - - 110 ); + + 11010 final isolate = await vm.Isolate.spawn( - 111 + 111 entryPoint, - 112 try { + 112 startRequest, - - 11310 final channel = await completer.future; + + 113 errorsAreFatal: false, - 1141 await hook?.call(isolate); + 11410 onExit: exitPort.sendPort, - 1152 logger?.t('Created Isolate'); + 11510 onError: errorPort.sendPort, - 116 return channel; + 116 ); - 117 } catch (ex) { + 117 - - 1183 logger?.e(() => 'Connection to Isolate failed: $ex'); + + 118 try { - 1193 isolate.kill(priority: vm.Isolate.beforeNextEvent); + 11910 final channel = await completer.future; - - 120 rethrow; + + 1201 await hook?.call(isolate); - - 121 } + + 1212 logger?.t('Created Isolate'); - 122} + 122 return channel; - 123 + 123 } catch (ex) { - - 124/// Creates a [_VmChannel] from a [SendPort]. + + 1243 logger?.e(() => 'Connection to Isolate failed: $ex'); - 1253Channel? deserialize(PlatformChannel? channelInfo, + 1253 isolate.kill(priority: vm.Isolate.beforeNextEvent); - 126 [Logger? logger, ExceptionManager? exceptionManager]) => + 126 rethrow; - 127 (channelInfo == null) + 127 } - 128 ? null + 128} - - 1293 : _VmChannel._( + + 129 - 130 channelInfo, + 130/// Creates a [_VmChannel] from a [SendPort]. - - 131 logger, + + 1313Channel? deserialize(PlatformChannel? channelInfo, - - 1323 exceptionManager ?? ExceptionManager(), + + 132 [Logger? logger, ExceptionManager? exceptionManager]) => - 133 ); + 133 (channelInfo == null) + + + 134 ? null + + + 1353 : _VmChannel._( + + + 136 channelInfo, + + + 137 logger, + + + 1383 exceptionManager ?? ExceptionManager(), + + + 139 ); diff --git a/doc/coverage/html/src/_impl/native/_channel_impl.dart.gcov.html b/doc/coverage/html/src/_impl/native/_channel_impl.dart.gcov.html index ef0e09ae..14ff9b57 100644 --- a/doc/coverage/html/src/_impl/native/_channel_impl.dart.gcov.html +++ b/doc/coverage/html/src/_impl/native/_channel_impl.dart.gcov.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
diff --git a/doc/coverage/html/src/_impl/native/_local_worker.dart.gcov.html b/doc/coverage/html/src/_impl/native/_local_worker.dart.gcov.html index 6262558d..52e99e2a 100644 --- a/doc/coverage/html/src/_impl/native/_local_worker.dart.gcov.html +++ b/doc/coverage/html/src/_impl/native/_local_worker.dart.gcov.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
diff --git a/doc/coverage/html/src/_impl/native/_platform.dart.gcov.html b/doc/coverage/html/src/_impl/native/_platform.dart.gcov.html index 2dd4c7d6..9e2c7607 100644 --- a/doc/coverage/html/src/_impl/native/_platform.dart.gcov.html +++ b/doc/coverage/html/src/_impl/native/_platform.dart.gcov.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
diff --git a/doc/coverage/html/src/_impl/native/_typedefs.dart.gcov.html b/doc/coverage/html/src/_impl/native/_typedefs.dart.gcov.html index 3465daa9..f5e55fc1 100644 --- a/doc/coverage/html/src/_impl/native/_typedefs.dart.gcov.html +++ b/doc/coverage/html/src/_impl/native/_typedefs.dart.gcov.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
diff --git a/doc/coverage/html/src/_impl/native/_worker_channel.dart.gcov.html b/doc/coverage/html/src/_impl/native/_worker_channel.dart.gcov.html index 4b293a1d..8115f923 100644 --- a/doc/coverage/html/src/_impl/native/_worker_channel.dart.gcov.html +++ b/doc/coverage/html/src/_impl/native/_worker_channel.dart.gcov.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
@@ -238,10 +238,10 @@

LCOV - code coverage report

59 /// must be called from the worker [Isolate] only. - 605 @override + 606 @override - 6110 void closeStream() => _postResponse(WorkerResponse.closeStream()); + 6112 void closeStream() => _postResponse(WorkerResponse.closeStream()); 62 diff --git a/doc/coverage/html/src/_impl/native/_worker_runner.dart.gcov.html b/doc/coverage/html/src/_impl/native/_worker_runner.dart.gcov.html index 7d1d1ef6..d39ed52f 100644 --- a/doc/coverage/html/src/_impl/native/_worker_runner.dart.gcov.html +++ b/doc/coverage/html/src/_impl/native/_worker_runner.dart.gcov.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
diff --git a/doc/coverage/html/src/_impl/native/index.html b/doc/coverage/html/src/_impl/native/index.html index 00b2517d..deef50c4 100644 --- a/doc/coverage/html/src/_impl/native/index.html +++ b/doc/coverage/html/src/_impl/native/index.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
@@ -39,7 +39,7 @@

LCOV - code coverage report

- Lines14816490.2% + Lines15316990.5% Functions00- @@ -79,11 +79,11 @@

LCOV - code coverage report

_channel.dart - 82.0% - 82.0%41/50-0/0-0/0 + 83.6% + 83.6%46/55-0/0-0/0 - <unnamed>82.0%41/50-0/0-0/0 + <unnamed>83.6%46/55-0/0-0/0 _local_worker.dart diff --git a/doc/coverage/html/src/_impl/web/_channel.dart.gcov.html b/doc/coverage/html/src/_impl/web/_channel.dart.gcov.html index ca64ce32..f800f3dd 100644 --- a/doc/coverage/html/src/_impl/web/_channel.dart.gcov.html +++ b/doc/coverage/html/src/_impl/web/_channel.dart.gcov.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
@@ -40,7 +40,7 @@

LCOV - code coverage report

- Lines667785.7% + Lines728386.7% Functions00- @@ -184,406 +184,433 @@

LCOV - code coverage report

41 final ready = Completer<bool>(); - 42 + 42 Channel? channel; - 43 final com = web.MessageChannel(); + 43 - - 4410 final webEntryPoint = EntryPointUri.from(entryPoint); + + 44 final com = web.MessageChannel(); - 4510 late web.Worker worker; + 4510 final webEntryPoint = EntryPointUri.from(entryPoint); - - 46 + + 4610 late web.Worker worker; - - 473 void fail(SquadronException ex) { + + 47 - 483 if (!ready.isCompleted) ready.completeError(ex); + 483 void fail(SquadronException ex) { - 493 if (!completer.isCompleted) completer.completeError(ex); + 493 if (!ready.isCompleted) ready.completeError(ex); - 503 } + 503 if (!completer.isCompleted) completer.completeError(ex); - - 51 + + 513 } - - 529 void success(Channel channel) { + + 52 - 539 if (!ready.isCompleted) { + 539 void success(Channel channel) { - - 540 throw SquadronErrorExt.create('Invalid state: worker is not ready'); + + 549 if (!ready.isCompleted) { - - 55 } + + 550 throw SquadronErrorExt.create('Invalid state: worker is not ready'); - - 569 if (!completer.isCompleted) completer.complete(channel); + + 56 } - 579 } + 579 if (!completer.isCompleted) completer.complete(channel); - - 58 + + 589 } - - 593 try { + + 59 - 6010 worker = web.Worker(webEntryPoint.uri.toJS); + 603 try { - - 61 + + 6110 worker = web.Worker(webEntryPoint.uri.toJS); - - 622 void $errorHandler(web.ErrorEvent? e) { + + 62 - 632 final err = getError(e), error = SquadronErrorExt.create(err.toString()); + 632 void $errorHandler(web.ErrorEvent? e) { - 642 logger?.e(() => 'Connection to Web Worker failed: $error'); + 642 final err = getError(e), error = SquadronErrorExt.create(err.toString()); - 652 fail(error); + 652 logger?.e(() => 'Connection to Web Worker failed: $error'); - - 66 + + 662 fail(error); - - 672 UriChecker.exists(entryPoint).then((found) { + + 67 - 682 try { + 682 UriChecker.exists(entryPoint).then((found) { - 692 final msg = (e != null) + 692 try { - 702 ? '$entryPoint => ${err.runtimeType} $err [${e.filename}(${e.lineno})]' + 702 final msg = (e != null) - - 710 : '$entryPoint => ${err.runtimeType} $err'; + + 712 ? '$entryPoint => ${err.runtimeType} $err [${e.filename}(${e.lineno})]' - - 721 logger?.e(() => 'Unhandled error from Web Worker: $msg.'); + + 720 : '$entryPoint => ${err.runtimeType} $err'; - - 730 if (!found) { + + 731 logger?.e(() => 'Unhandled error from Web Worker: $msg.'); - - 742 logger?.e(() => 'It seems no Web Worker lives at $entryPoint.'); + + 740 if (!found) { - - 75 } + + 752 logger?.e(() => 'It seems no Web Worker lives at $entryPoint.'); - 76 } catch (_) { + 76 } - 77 // ignore + 77 } catch (_) { - 78 } + 78 // ignore - - 792 }); + + 79 } - 802 } + 802 }); - - 81 + + 812 } - - 8210 worker.onerror = $errorHandler.toJS; + + 82 - 8310 worker.onmessageerror = $errorHandler.toJS; + 8310 worker.onerror = $errorHandler.toJS; - - 84 + + 8410 worker.onmessageerror = $errorHandler.toJS; - 85 final disconnected = DisconnectedChannel(exceptionManager, logger); + 85 - 86 + 86 final disconnected = DisconnectedChannel(exceptionManager, logger); - - 8710 worker.onmessage = (web.MessageEvent? e) { + + 87 - 8810 try { + 8810 worker.onmessage = (web.MessageEvent? e) { - 8910 final response = WorkerResponseExt.from(getMessageEventData(e) as List); + 8910 try { - 9010 if (!response.unwrapInPlace(disconnected)) { + 9010 final response = WorkerResponseExt.from(getMessageEventData(e) as List); - - 910 return; + + 9110 if (!response.unwrapInPlace(disconnected)) { - - 92 } + + 920 return; - 93 + 93 } - 94 final error = response.error; + 94 - - 9510 if (error != null) { + + 95 final error = response.error; - 962 logger?.e(() => 'Connection to Web Worker failed: $error'); + 9610 if (error != null) { - 972 fail(error); + 972 logger?.e(() => 'Connection to Web Worker failed: $error'); - 989 } else if (!ready.isCompleted) { + 982 fail(error); - 992 logger?.t('Web Worker is ready'); + 999 } else if (!ready.isCompleted) { - 1009 ready.complete(response.result); + 1002 logger?.t('Web Worker is ready'); - - 101 } + + 1019 ready.complete(response.result); - - 1020 } catch (ex, st) { + + 102 } - 1030 return fail(SquadronException.from(ex, st)); + 1030 } catch (ex, st) { - - 104 } + + 1040 return fail(SquadronException.from(ex, st)); - - 10510 }.toJS; + + 105 } - - 106 + + 10610 }.toJS; - - 10710 final res = await ready.future; + + 107 - - 108 if (!res) { + + 10810 final res = await ready.future; - - 1090 throw SquadronErrorExt.create('Web Worker is not ready'); + + 109 if (!res) { - - 110 } + + 1100 throw SquadronErrorExt.create('Web Worker is not ready'); - 111 + 111 } - 112 final startRequest = WorkerRequest.start(com.port2, startArguments); + 112 - 113 + 113 final startRequest = WorkerRequest.start(com.port2, startArguments); - - 1149 com.port1.onmessage = (web.MessageEvent e) { + + 114 - 1159 final response = WorkerResponseExt.from(getMessageEventData(e) as List); + 1159 com.port1.onmessage = (web.MessageEvent e) { - 1169 if (!response.unwrapInPlace(disconnected)) { + 1169 final response = WorkerResponseExt.from(getMessageEventData(e) as List); - 1179 return; + 1179 if (!response.unwrapInPlace(disconnected)) { - - 118 } + + 1189 return; - 119 + 119 } - 120 final error = response.error; + 120 - - 1219 if (error != null) { + + 121 final error = response.error; - 1222 logger?.e(() => 'Connection to Web Worker failed: $error'); + 1229 if (error != null) { - 1232 fail(error); + 1232 logger?.e(() => 'Connection to Web Worker failed: $error'); - 1249 } else if (!completer.isCompleted) { + 1242 fail(error); - - 1252 logger?.t('Connected to Web Worker'); + + 125 } else if (response.endOfStream) { - 1269 success(_WebChannel._(response.result, logger, exceptionManager)); + 1261 logger?.w('Disconnecting from Isolate'); - - 127 } else { + + 1271 channel?.close(); - 1282 logger?.d(() => 'Unexpected response: $response'); + 1289 } else if (!completer.isCompleted) { - - 129 } + + 1292 logger?.t('Connected to Web Worker'); - 1309 }.toJS; + 1309 channel = _WebChannel._(response.result, logger, exceptionManager); - - 131 + + 1319 success(channel!); - - 1320 try { + + 132 } else { - 1339 final data = startRequest.wrapInPlace(); + 1332 logger?.d(() => 'Unexpected response: $response'); - 134 final msg = data.jsify(); + 134 } - 1359 final transfer = Transferables.get(data); + 1359 }.toJS; - 136 if (transfer == null || transfer.isEmpty) { + 136 - - 137 worker.postMessage(msg); + + 1370 try { - - 138 } else { + + 1389 final data = startRequest.wrapInPlace(); - - 1399 final jsTransfer = transfer.jsify() as JSArray; + + 139 final msg = data.jsify(); - - 140 worker.postMessage(msg, jsTransfer); + + 1409 final transfer = Transferables.get(data); - 141 } + 141 if (transfer == null || transfer.isEmpty) { - - 1420 } catch (ex, st) { + + 142 worker.postMessage(msg); - - 1432 logger?.e(() => 'Failed to post connection request $startRequest: $ex'); + + 143 } else { - - 1440 throw SquadronErrorExt.create( + + 1449 final jsTransfer = transfer.jsify() as JSArray; - - 1450 'Failed to post connection request: $ex', st); + + 145 worker.postMessage(msg, jsTransfer); - 146 } + 146 } - - 147 + + 1470 } catch (ex, st) { - 1489 final channel = await completer.future; + 1482 logger?.e(() => 'Failed to post connection request $startRequest: $ex'); - - 1499 await hook?.call(worker); + + 1490 throw SquadronErrorExt.create( - - 150 + + 1500 'Failed to post connection request: $ex', st); - - 1512 logger?.t('Created Web Worker for $entryPoint'); + + 151 } - - 1529 return channel; + + 152 - 1533 } catch (ex, st) { + 1532 try { - 1543 ready.future.ignore(); + 1549 final channel = await completer.future; - 1553 completer.future.ignore(); + 1559 await hook?.call(worker); - 1561 logger?.t('Failed to create Web Worker for $entryPoint'); + 1562 logger?.t('Created Web Worker for $entryPoint'); - - 157 com.port1.close(); + + 1579 return channel; - 158 com.port2.close(); + 158 } catch (ex) { - - 159 worker.terminate(); + + 1592 logger?.e(() => 'Connection to Isolate failed: $ex'); - 1603 throw SquadronException.from(ex, st); + 1602 rethrow; - 161 } finally { + 161 } - - 162 webEntryPoint.release(); + + 1623 } catch (ex, st) { - - 163 } + + 1633 ready.future.ignore(); - 16410} + 1643 completer.future.ignore(); - - 165 + + 1651 logger?.t('Failed to create Web Worker for $entryPoint'); - 166/// Creates a [_WebChannel] from a [web.MessagePort]. + 166 com.port1.close(); - 167Channel? deserialize(PlatformChannel? channelInfo, + 167 com.port2.close(); - 168 [Logger? logger, ExceptionManager? exceptionManager]) => + 168 worker.terminate(); - - 169 (channelInfo == null) + + 1693 throw SquadronException.from(ex, st); - 170 ? null + 170 } finally { - 171 : _WebChannel._( + 171 webEntryPoint.release(); - 172 channelInfo, + 172 } - - 173 logger, + + 17310} - 174 exceptionManager ?? ExceptionManager(), + 174 - 175 ); + 175/// Creates a [_WebChannel] from a [web.MessagePort]. + + + 176Channel? deserialize(PlatformChannel? channelInfo, + + + 177 [Logger? logger, ExceptionManager? exceptionManager]) => + + + 178 (channelInfo == null) + + + 179 ? null + + + 180 : _WebChannel._( + + + 181 channelInfo, + + + 182 logger, + + + 183 exceptionManager ?? ExceptionManager(), + + + 184 ); diff --git a/doc/coverage/html/src/_impl/web/_channel_impl.dart.gcov.html b/doc/coverage/html/src/_impl/web/_channel_impl.dart.gcov.html index 7b0eab9c..a42ea166 100644 --- a/doc/coverage/html/src/_impl/web/_channel_impl.dart.gcov.html +++ b/doc/coverage/html/src/_impl/web/_channel_impl.dart.gcov.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
@@ -382,7 +382,7 @@

LCOV - code coverage report

107 - 1089 void $forwardMessage(WorkerResponse msg) => controller?.add(msg); + 10810 void $forwardMessage(WorkerResponse msg) => controller?.add(msg); 109 @@ -463,19 +463,19 @@

LCOV - code coverage report

134 - 1359 com.port1.onmessage = (web.MessageEvent e) { + 13510 com.port1.onmessage = (web.MessageEvent e) { - 1369 final res = WorkerResponseExt.from(getMessageEventData(e)!); + 13610 final res = WorkerResponseExt.from(getMessageEventData(e)!); - 1379 final handler = buffer.isActive ? buffer.add : $forwardMessage; + 13710 final handler = buffer.isActive ? buffer.add : $forwardMessage; - 1389 handler(res); + 13810 handler(res); - 1399 }.toJS; + 13910 }.toJS; 140 diff --git a/doc/coverage/html/src/_impl/web/_entry_point_uri.dart.gcov.html b/doc/coverage/html/src/_impl/web/_entry_point_uri.dart.gcov.html index 6dede411..5d496af4 100644 --- a/doc/coverage/html/src/_impl/web/_entry_point_uri.dart.gcov.html +++ b/doc/coverage/html/src/_impl/web/_entry_point_uri.dart.gcov.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
diff --git a/doc/coverage/html/src/_impl/web/_event_buffer.dart.gcov.html b/doc/coverage/html/src/_impl/web/_event_buffer.dart.gcov.html index 3c99f66b..5a1be923 100644 --- a/doc/coverage/html/src/_impl/web/_event_buffer.dart.gcov.html +++ b/doc/coverage/html/src/_impl/web/_event_buffer.dart.gcov.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
@@ -103,7 +103,7 @@

LCOV - code coverage report

14 - 159 bool get isActive => _pauses > 0; + 1510 bool get isActive => _pauses > 0; 16 diff --git a/doc/coverage/html/src/_impl/web/_local_worker.dart.gcov.html b/doc/coverage/html/src/_impl/web/_local_worker.dart.gcov.html index 1348f0a2..34dc4174 100644 --- a/doc/coverage/html/src/_impl/web/_local_worker.dart.gcov.html +++ b/doc/coverage/html/src/_impl/web/_local_worker.dart.gcov.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
diff --git a/doc/coverage/html/src/_impl/web/_patch.dart.gcov.html b/doc/coverage/html/src/_impl/web/_patch.dart.gcov.html index 3c68714b..253a4dfb 100644 --- a/doc/coverage/html/src/_impl/web/_patch.dart.gcov.html +++ b/doc/coverage/html/src/_impl/web/_patch.dart.gcov.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
@@ -151,13 +151,13 @@

LCOV - code coverage report

30 - 3110List? getMessageEventData(JSObject? obj) { + 3111List? getMessageEventData(JSObject? obj) { - 3210 if (obj != null && obj.has('data')) { + 3211 if (obj != null && obj.has('data')) { - 3310 return obj['data'].dartify() as List?; + 3311 return obj['data'].dartify() as List?; 34 } else { @@ -169,7 +169,7 @@

LCOV - code coverage report

36 } - 3710} + 3711} diff --git a/doc/coverage/html/src/_impl/web/_platform.dart.gcov.html b/doc/coverage/html/src/_impl/web/_platform.dart.gcov.html index 50b7d255..db11f00d 100644 --- a/doc/coverage/html/src/_impl/web/_platform.dart.gcov.html +++ b/doc/coverage/html/src/_impl/web/_platform.dart.gcov.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
diff --git a/doc/coverage/html/src/_impl/web/_typedefs.dart.gcov.html b/doc/coverage/html/src/_impl/web/_typedefs.dart.gcov.html index e6d18f62..914eef83 100644 --- a/doc/coverage/html/src/_impl/web/_typedefs.dart.gcov.html +++ b/doc/coverage/html/src/_impl/web/_typedefs.dart.gcov.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
diff --git a/doc/coverage/html/src/_impl/web/_uri_checker.dart.gcov.html b/doc/coverage/html/src/_impl/web/_uri_checker.dart.gcov.html index 27c35d41..cea0654b 100644 --- a/doc/coverage/html/src/_impl/web/_uri_checker.dart.gcov.html +++ b/doc/coverage/html/src/_impl/web/_uri_checker.dart.gcov.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
diff --git a/doc/coverage/html/src/_impl/web/_worker_channel.dart.gcov.html b/doc/coverage/html/src/_impl/web/_worker_channel.dart.gcov.html index 9db446fe..464a3630 100644 --- a/doc/coverage/html/src/_impl/web/_worker_channel.dart.gcov.html +++ b/doc/coverage/html/src/_impl/web/_worker_channel.dart.gcov.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
diff --git a/doc/coverage/html/src/_impl/web/_worker_runner.dart.gcov.html b/doc/coverage/html/src/_impl/web/_worker_runner.dart.gcov.html index 373010b7..54922d27 100644 --- a/doc/coverage/html/src/_impl/web/_worker_runner.dart.gcov.html +++ b/doc/coverage/html/src/_impl/web/_worker_runner.dart.gcov.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
diff --git a/doc/coverage/html/src/_impl/web/index.html b/doc/coverage/html/src/_impl/web/index.html index 57aa249c..35efa318 100644 --- a/doc/coverage/html/src/_impl/web/index.html +++ b/doc/coverage/html/src/_impl/web/index.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
@@ -39,7 +39,7 @@

LCOV - code coverage report

- Lines25631381.8% + Lines26231982.1% Functions00- @@ -71,11 +71,11 @@

LCOV - code coverage report

_channel.dart - 85.7% - 85.7%66/77-0/0-0/0 + 86.7% + 86.7%72/83-0/0-0/0 - <unnamed>85.7%66/77-0/0-0/0 + <unnamed>86.7%72/83-0/0-0/0 _entry_point_uri.dart diff --git a/doc/coverage/html/src/_impl/xplat/_disconnected_channel.dart.gcov.html b/doc/coverage/html/src/_impl/xplat/_disconnected_channel.dart.gcov.html index d5feb579..4f06a0c7 100644 --- a/doc/coverage/html/src/_impl/xplat/_disconnected_channel.dart.gcov.html +++ b/doc/coverage/html/src/_impl/xplat/_disconnected_channel.dart.gcov.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
diff --git a/doc/coverage/html/src/_impl/xplat/_forward_completer.dart.gcov.html b/doc/coverage/html/src/_impl/xplat/_forward_completer.dart.gcov.html index 57e6487e..de4c04ef 100644 --- a/doc/coverage/html/src/_impl/xplat/_forward_completer.dart.gcov.html +++ b/doc/coverage/html/src/_impl/xplat/_forward_completer.dart.gcov.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
diff --git a/doc/coverage/html/src/_impl/xplat/_forward_stream_controller.dart.gcov.html b/doc/coverage/html/src/_impl/xplat/_forward_stream_controller.dart.gcov.html index d259254d..5553fad2 100644 --- a/doc/coverage/html/src/_impl/xplat/_forward_stream_controller.dart.gcov.html +++ b/doc/coverage/html/src/_impl/xplat/_forward_stream_controller.dart.gcov.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
@@ -109,7 +109,7 @@

LCOV - code coverage report

16 - 179 late final StreamController<T> _controller; + 1710 late final StreamController<T> _controller; 18 @@ -145,13 +145,13 @@

LCOV - code coverage report

28 - 2914 void add(T data) { + 2915 void add(T data) { - 3045 if (!_controller.isClosed) _controller.add(data); + 3046 if (!_controller.isClosed) _controller.add(data); - 315 } + 316 } 32 @@ -160,7 +160,7 @@

LCOV - code coverage report

336 void addError(SquadronException ex) { - 3431 if (!_controller.isClosed) _controller.addError(ex); + 3432 if (!_controller.isClosed) _controller.addError(ex); 35 } diff --git a/doc/coverage/html/src/_impl/xplat/_internal_logger.dart.gcov.html b/doc/coverage/html/src/_impl/xplat/_internal_logger.dart.gcov.html index 4a3bc9dd..bb22fccc 100644 --- a/doc/coverage/html/src/_impl/xplat/_internal_logger.dart.gcov.html +++ b/doc/coverage/html/src/_impl/xplat/_internal_logger.dart.gcov.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
diff --git a/doc/coverage/html/src/_impl/xplat/_result_stream.dart.gcov.html b/doc/coverage/html/src/_impl/xplat/_result_stream.dart.gcov.html index f6b119a1..2d59d6d8 100644 --- a/doc/coverage/html/src/_impl/xplat/_result_stream.dart.gcov.html +++ b/doc/coverage/html/src/_impl/xplat/_result_stream.dart.gcov.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
@@ -118,16 +118,16 @@

LCOV - code coverage report

19 - 2014 void $decodeStreamOfResponses(WorkerResponse res) { + 2015 void $decodeStreamOfResponses(WorkerResponse res) { - 2110 if (!res.unwrapInPlace(channel)) return; + 2111 if (!res.unwrapInPlace(channel)) return; 22 - 2310 final hasStreamId = streamIdCompleter!.isCompleted; + 2311 final hasStreamId = streamIdCompleter!.isCompleted; 245 if (res.endOfStream) { @@ -169,7 +169,7 @@

LCOV - code coverage report

365 final error = res.error; - 375 if (error == null && !hasStreamId) { + 376 if (error == null && !hasStreamId) { 38 // the first result from a streaming operation is the stream ID @@ -178,7 +178,7 @@

LCOV - code coverage report

3920 streamIdCompleter.complete((res.result as num).toInt()); - 405 } else if (error != null) { + 406 } else if (error != null) { 4110 _controller.addError(error); @@ -208,7 +208,7 @@

LCOV - code coverage report

490 try { - 5020 _controller.add(res.result); + 5021 _controller.add(res.result); 510 } catch (ex, st) { @@ -226,10 +226,10 @@

LCOV - code coverage report

55 - 567 final canceled = token?.exception; + 568 final canceled = token?.exception; - 575 if (canceled != null) { + 576 if (canceled != null) { 580 _controller.addError(canceled); @@ -241,7 +241,7 @@

LCOV - code coverage report

60 } - 615 } + 616 } 62 @@ -481,7 +481,7 @@

LCOV - code coverage report

140 - 1419 late final ForwardStreamController<dynamic> _controller; + 14110 late final ForwardStreamController<dynamic> _controller; 142 diff --git a/doc/coverage/html/src/_impl/xplat/_time_stamp.dart.gcov.html b/doc/coverage/html/src/_impl/xplat/_time_stamp.dart.gcov.html index ea0c3e23..560e9edf 100644 --- a/doc/coverage/html/src/_impl/xplat/_time_stamp.dart.gcov.html +++ b/doc/coverage/html/src/_impl/xplat/_time_stamp.dart.gcov.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
diff --git a/doc/coverage/html/src/_impl/xplat/_token_id.dart.gcov.html b/doc/coverage/html/src/_impl/xplat/_token_id.dart.gcov.html index 3e215c30..ce934915 100644 --- a/doc/coverage/html/src/_impl/xplat/_token_id.dart.gcov.html +++ b/doc/coverage/html/src/_impl/xplat/_token_id.dart.gcov.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
diff --git a/doc/coverage/html/src/_impl/xplat/_transferables.dart.gcov.html b/doc/coverage/html/src/_impl/xplat/_transferables.dart.gcov.html index e38add4d..db8ffad9 100644 --- a/doc/coverage/html/src/_impl/xplat/_transferables.dart.gcov.html +++ b/doc/coverage/html/src/_impl/xplat/_transferables.dart.gcov.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
diff --git a/doc/coverage/html/src/_impl/xplat/_worker_runner.dart.gcov.html b/doc/coverage/html/src/_impl/xplat/_worker_runner.dart.gcov.html index 343baca0..0e97b49d 100644 --- a/doc/coverage/html/src/_impl/xplat/_worker_runner.dart.gcov.html +++ b/doc/coverage/html/src/_impl/xplat/_worker_runner.dart.gcov.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
@@ -40,7 +40,7 @@

LCOV - code coverage report

- Lines12514785.0% + Lines13716483.5% Functions00- @@ -73,10 +73,10 @@

LCOV - code coverage report

4 - 5import '../../exceptions/squadron_error.dart'; + 5import '../../../squadron.dart'; - 6import '../../local_worker/local_worker.dart'; + 6import '../../exceptions/squadron_error.dart'; 7import '../../tokens/_cancelation_token_ref.dart'; @@ -85,208 +85,208 @@

LCOV - code coverage report

8import '../../tokens/_squadron_cancelation_token.dart'; - 9import '../../typedefs.dart'; + 9import '../../worker/worker_request.dart'; - 10import '../../worker/worker_channel.dart'; + 10import '_internal_logger.dart'; - 11import '../../worker/worker_request.dart'; + 11 - 12import '../../worker_service.dart'; + 12class WorkerRunner { - 13import '_internal_logger.dart'; + 13 /// Constructs a new worker runner. - - 14 + + 1410 WorkerRunner(this._terminate); - 15class WorkerRunner { + 15 - 16 /// Constructs a new worker runner. + 16 void Function(WorkerRunner) _terminate; - - 1710 WorkerRunner(this._terminate); + + 17 - 18 + 18 final internalLogger = InternalLogger(); - 19 void Function(WorkerRunner) _terminate; + 19 - 20 + 20 WorkerService? _service; - 21 final internalLogger = InternalLogger(); + 21 - - 22 + + 221 final _cancelTokens = <String, CancelationTokenReference>{}; - - 231 Map<int, CommandHandler>? _operations; + + 23 - 24 ServiceInstaller? _installer; + 24 bool _terminationRequested = false; - 25 + 25 int _executing = 0; - - 261 final _cancelTokens = <String, CancelationTokenReference>{}; + + 26 - - 27 + + 271 final _streamCancelers = <int, SquadronCallback>{}; - 28 bool _terminationRequested = false; + 28 int _streamId = 0; - 29 int _executing = 0; + 29 - 30 + 30 void Function(OutputEvent)? _logForwarder; - - 311 final _streamCancelers = <int, SquadronCallback>{}; + + 31 - 32 int _streamId = 0; + 32 /// Constructs a new worker runner for a [localWorker]. - - 33 + + 332 factory WorkerRunner.use(LocalWorker localWorker) { - - 34 void Function(OutputEvent)? _logForwarder; + + 342 final runner = WorkerRunner((r) { - - 35 + + 350 r.internalLogger.t('Terminating local Worker'); - - 36 /// Constructs a new worker runner for a [localWorker]. + + 360 r._service = null; - - 372 factory WorkerRunner.use(LocalWorker localWorker) { + + 370 }); - 382 final runner = WorkerRunner((r) => r._operations?.clear()); + 382 runner._service = localWorker; - 395 runner._operations = {...localWorker.service.operations}; + 391 return runner; - 401 return runner; + 401 } - - 411 } + + 41 - 42 + 42 /// Called by the platform worker upon startup, in response to a start - 43 /// Called by the platform worker upon startup, in response to a start + 43 /// [WorkerRequest]. [channelInfo] is an opaque object sent back from the - 44 /// [WorkerRequest]. [channelInfo] is an opaque object sent back from the + 44 /// platform worker to the Squadron [Worker] and used to communicate with the - 45 /// platform worker to the Squadron [Worker] and used to communicate with the + 45 /// platform worker. Typically, [channelInfo] would be a [SendPort] (native) - 46 /// platform worker. Typically, [channelInfo] would be a [SendPort] (native) + 46 /// or a [MessagePort] (browser). [initializer] is called to build the - 47 /// or a [MessagePort] (browser). [initializer] is called to build the + 47 /// [WorkerService] associated to the worker. The runner's [_service] map - 48 /// [WorkerService] associated to the worker. The runner's [_operations] map + 48 /// will be set with operations from the service. - - 49 /// will be set with operations from the service. + + 499 Future<void> connect(WorkerRequest? startRequest, PlatformChannel channelInfo, - - 509 Future<void> connect(WorkerRequest? startRequest, PlatformChannel channelInfo, + + 50 WorkerInitializer initializer) async { - 51 WorkerInitializer initializer) async { + 51 WorkerChannel? channel; - 52 WorkerChannel? channel; + 52 try { - - 53 try { + + 5318 startRequest?.unwrapInPlace(internalLogger); - 5418 startRequest?.unwrapInPlace(internalLogger); + 549 channel = startRequest?.channel; - - 559 channel = startRequest?.channel; + + 55 - 56 + 56 if (startRequest == null) { - - 57 if (startRequest == null) { + + 572 throw SquadronErrorExt.create('Missing connection request'); - - 582 throw SquadronErrorExt.create('Missing connection request'); + + 58 } else if (channel == null) { - - 59 } else if (channel == null) { + + 590 throw SquadronErrorExt.create('Missing client for connection request'); - - 600 throw SquadronErrorExt.create('Missing client for connection request'); + + 60 } - 61 } + 61 - - 62 + + 629 if (_logForwarder == null) { - 639 if (_logForwarder == null) { + 639 final logger = channel.log; - 649 final logger = channel.log; + 6436 _logForwarder = (event) => logger(event.origin); - 6536 _logForwarder = (event) => logger(event.origin); + 6518 Logger.addOutputListener(_logForwarder!); - - 6618 Logger.addOutputListener(_logForwarder!); + + 66 } - 67 } + 67 - - 68 + + 689 if (!startRequest.isConnection) { - - 699 if (!startRequest.isConnection) { + + 690 throw SquadronErrorExt.create('Connection request expected'); - - 700 throw SquadronErrorExt.create('Connection request expected'); + + 709 } else if (_service != null) { - - 719 } else if (_operations != null) { + + 710 throw SquadronErrorExt.create('Already connected'); - - 720 throw SquadronErrorExt.create('Already connected'); + + 72 } - 73 } + 73 - - 74 + + 7418 _service = await initializer(startRequest); - - 759 final service = await initializer(startRequest); + + 75 - 7654 if (service.operations.keys.where((k) => k <= 0).isNotEmpty) { + 7663 if (_service!.operations.keys.where((k) => k <= 0).isNotEmpty) { 772 throw SquadronErrorExt.create( @@ -304,112 +304,112 @@

LCOV - code coverage report

81 - 8227 _operations = {...service.operations}; + 829 channel.connect(channelInfo); 83 - 849 if (service is ServiceInstaller) { + 8418 if (_service is ServiceInstaller) { - 851 _installer = service as ServiceInstaller; + 852 _installCompleter = Completer() - 862 await _installer!.install(); + 862 ..complete((() async { - 87 } + 87 try { - - 88 + + 882 await (_service as ServiceInstaller).install(); - - 899 channel.connect(channelInfo); + + 89 } catch (ex, st) { - - 90 } catch (ex, st) { + + 904 internalLogger.e(() => 'Service installation failed: $ex'); - 918 internalLogger.e(() => 'Connection failed: $ex'); + 911 channel?.error(ex, st); - 922 channel?.error(ex, st); + 921 channel?.closeStream(); - 932 _exit(); + 932 _installResult = SquadronException.from(ex, st); - 94 } + 94 } - - 95 } + + 951 })()); - 96 + 96 } - 97 /// [WorkerRequest] handler dispatching commands according to the + 97 } catch (ex, st) { - - 98 /// [_operations] map. Make sure this method doesn't throw. + + 988 internalLogger.e(() => 'Connection failed: $ex'); - 9910 void processRequest(WorkerRequest request) async { + 992 channel?.error(ex, st); - 1001 WorkerChannel? channel; + 1002 _exit(); - - 1011 try { + + 101 } - - 10219 request.unwrapInPlace(internalLogger); + + 102 } - - 1039 channel = request.channel; + + 103 - 104 + 104 Completer<void>? _installCompleter; - 105 // ==== these requests do not send a response ==== + 105 SquadronException? _installResult; 106 - - 1079 if (request.isTermination) { + + 107 /// [WorkerRequest] handler dispatching commands according to the - 108 // terminate the worker + 108 /// [_service] map. Make sure this method doesn't throw. - 1099 return _shutdown(); + 10910 void processRequest(WorkerRequest request) async { - 1109 } else if (request.isTokenCancelation) { + 1101 WorkerChannel? channel; - - 111 // cancel a token + + 1111 try { - 1122 final token = request.cancelToken!; + 11219 request.unwrapInPlace(internalLogger); - 1134 return _getTokenRef(token).update(token); + 1139 channel = request.channel; - - 1149 } else if (request.isStreamCancelation) { + + 114 - - 115 // cancel a stream + + 1159 if (request.isTermination) { - - 1169 final canceler = _streamCancelers[request.streamId]; + + 116 // terminate the worker - 1173 return canceler?.call(); + 1179 return _shutdown(); 118 } @@ -418,604 +418,709 @@

LCOV - code coverage report

119 - 120 // make sure the worker is connected + 120 // check installation result if necessary - - 121 + + 12110 final pendingInstallation = _installCompleter?.future; - 1229 if (request.isConnection) { + 1221 if (pendingInstallation != null) { - - 123 // connection requests are handled by connect(). + + 1230 await pendingInstallation; - - 1240 throw SquadronErrorExt.create( + + 1241 _installCompleter = null; - - 1250 'Unexpected connection request: $request'); + + 125 } - - 12610 } else if (_operations == null) { + + 126 - - 127 // commands are not available yet (maybe connect() wasn't called or awaited) + + 12710 if (_installResult != null) { - - 1280 throw SquadronErrorExt.create('Worker service is not ready'); + + 128 // service installation failed - - 129 } + + 1291 throw _installResult!; - 130 + 130 } - 131 // ==== other requests require a client to send the response ==== + 131 - 132 + 132 // ==== these requests do not send a response ==== - 133 if (channel == null) { + 133 - - 1340 throw SquadronErrorExt.create('Missing client for request: $request'); + + 1349 if (request.isTokenCancelation) { - 135 } + 135 // cancel a token - - 136 + + 1362 final token = request.cancelToken!; - 1379 final token = request.cancelToken; + 1374 return _getTokenRef(token).update(token); - 1382 token?.throwIfCanceled(); + 1389 } else if (request.isStreamCancelation) { - 139 + 139 // cancel a stream - - 140 // start monitoring execution + + 1409 final canceler = _streamCancelers[request.streamId]; - 1419 final tokenRef = _begin(request); + 1413 return canceler?.call(); - 142 try { + 142 } - 143 // find the operation matching the request command + 143 - - 14428 final cmd = request.command, op = _operations![cmd]; + + 144 // make sure the worker is connected - 145 if (op == null) { + 145 - 1462 throw SquadronErrorExt.create('Unknown command: $cmd'); + 1469 if (request.isConnection) { - 147 } + 147 // connection requests are handled by connect(). - - 148 + + 1480 throw SquadronErrorExt.create( - - 149 // process + + 1490 'Unexpected connection request: $request'); - 15010 var result = op(request); + 15010 } else if (_service == null) { - - 15110 if (result is Future) { + + 151 // commands are not available yet (maybe connect() wasn't called or awaited) - 1520 result = await result; + 1520 throw SquadronErrorExt.create('Worker service is not ready'); - 153 } + 153 } 154 - - 15510 final reply = request.reply!; + + 155 // ==== other requests require a client to send the response ==== - - 15616 if (result is Stream && channel.canStream(result)) { + + 156 - 157 // result is a stream: forward data to the client + 157 if (channel == null) { - - 1586 final replyWithError = channel.error; + + 1580 throw SquadronErrorExt.create('Missing client for request: $request'); - - 1593 void postError(Object exception, [StackTrace? stackTrace]) { + + 159 } - - 1603 replyWithError(exception, stackTrace, cmd); + + 160 - - 1610 } + + 1619 final token = request.cancelToken; - - 162 + + 1622 token?.throwIfCanceled(); - - 1636 void post(data) { + + 163 - - 1641 try { + + 164 // start monitoring execution - 1656 reply(data); + 1659 final tokenRef = _begin(request); - - 1660 } catch (ex, st) { + + 166 try { - - 1670 postError(ex, st); + + 167 // find the operation matching the request command - - 168 } + + 16837 final cmd = request.command, op = _service?.operations[cmd]; - - 1691 } + + 169 if (op == null) { - - 170 + + 1702 throw SquadronErrorExt.create('Unknown command: $cmd'); - - 1716 await _pipe(result, channel, post, postError, token); + + 171 } - 172 } else { + 172 - 173 // result is a value: send to the client + 173 // process - 1749 reply(result); + 17410 var result = op(request); - - 175 } + + 17510 if (result is Future) { - - 176 } finally { + + 1760 result = await result; - 177 // stop monitoring execution + 177 } - - 1789 _done(tokenRef); + + 178 - - 179 } + + 17910 final reply = request.reply!; - 1801 } catch (ex, st) { + 18016 if (result is Stream && channel.canStream(result)) { - 181 if (channel != null) { + 181 // result is a stream: forward data to the client - 1826 channel.error(ex, st, request.command); + 1826 final replyWithError = channel.error; - - 183 } else { + + 1833 void postError(Object exception, [StackTrace? stackTrace]) { - 1843 internalLogger.e('Unhandled error: $ex'); + 1843 replyWithError(exception, stackTrace, cmd); - - 185 } + + 1850 } - 186 } + 186 - 1871 } + 1876 void post(data) { - - 188 + + 1881 try { - 18910 CancelationTokenReference _getTokenRef(SquadronCancelationToken? token) => + 1896 reply(data); - - 1901 (token == null) + + 1900 } catch (ex, st) { - - 19110 ? CancelationTokenReference.noToken + + 1910 postError(ex, st); - - 1924 : _cancelTokens.putIfAbsent( + + 192 } - 1939 token.id, () => CancelationTokenReference(token.id)); + 1931 } 194 - - 195 /// Starts monitoring execution of this [request]. If the request contains a + + 1956 await _pipe(result, channel, post, postError, token); - 196 /// cancelation token, it is overridden with a [CancelationTokenReference] + 196 } else { - 197 /// and this reference is returned to the sender. Otherwise, returns + 197 // result is a value: send to the client - - 198 /// [CancelationTokenReference.noToken]. + + 1989 reply(result); - - 1999 CancelationTokenReference _begin(WorkerRequest request) { + + 199 } - - 20018 _executing++; + + 200 } finally { - - 20119 final token = _getTokenRef(request.cancelToken); + + 201 // stop monitoring execution - 2029 token.usedBy(request); + 2029 _done(tokenRef); - 203 return token; + 203 } - - 204 } + + 2041 } catch (ex, st) { - 205 + 205 if (channel != null) { - - 206 /// Stops monitoring execution and releases the [tokenRef]. + + 2066 channel.error(ex, st, request.command); - - 2079 void _done(CancelationTokenReference tokenRef) { + + 207 } else { - 20810 tokenRef.release(); + 2083 internalLogger.e('Unhandled error: $ex'); - - 20918 if (tokenRef.refCount == 0) { + + 209 } - - 2106 _cancelTokens.remove(tokenRef.id); + + 210 } - - 211 } + + 2111 } - - 21218 _executing--; + + 212 - 21314 if (_terminationRequested && _executing == 0) { + 21310 CancelationTokenReference _getTokenRef(SquadronCancelationToken? token) => - 2142 _unmount(); + 2141 (token == null) - - 215 } + + 21510 ? CancelationTokenReference.noToken - - 216 } + + 2164 : _cancelTokens.putIfAbsent( - - 217 + + 2179 token.id, () => CancelationTokenReference(token.id)); - 218 /// Forwards stream events to client. + 218 - - 2196 Future<void> _pipe( + + 219 /// Starts monitoring execution of this [request]. If the request contains a - 220 Stream<dynamic> stream, + 220 /// cancelation token, it is overridden with a [CancelationTokenReference] - 221 WorkerChannel channel, + 221 /// and this reference is returned to the sender. Otherwise, returns - 222 void Function(dynamic) post, + 222 /// [CancelationTokenReference.noToken]. - - 223 void Function(Object exception, [StackTrace? stackTrace]) postError, + + 2239 CancelationTokenReference _begin(WorkerRequest request) { - - 224 SquadronCancelationToken? token, + + 22418 _executing++; - - 225 ) { + + 22519 final token = _getTokenRef(request.cancelToken); - 2261 late final StreamSubscription subscription; + 2269 token.usedBy(request); - - 2275 final done = Completer(); + + 227 return token; - 228 + 228 } - - 2291 late final int streamId; + + 229 - 230 + 230 /// Stops monitoring execution and releases the [tokenRef]. - - 231 // send endOfStream to client + + 2319 void _done(CancelationTokenReference tokenRef) { - 2326 Future<void> onDone() async { + 23210 tokenRef.release(); - 2336 _unregisterStreamCanceler(streamId); + 23318 if (tokenRef.refCount == 0) { - 2346 channel.closeStream(); + 2346 _cancelTokens.remove(tokenRef.id); - - 2356 await subscription.cancel(); + + 235 } - 2366 done.complete(); + 23618 _executing--; - 2371 } + 23714 if (_terminationRequested && _executing == 0) { - - 238 + + 2382 _unmount(); - 239 final bool Function() checkToken; + 239 } - 240 if (token == null) { + 240 } - - 2416 checkToken = () => true; + + 241 - 242 } else { + 242 /// Forwards stream events to client. - 2432 checkToken = () { + 2436 Future<void> _pipe( - - 2442 final ex = token.exception; + + 244 Stream<dynamic> stream, - - 2450 if (ex != null) { + + 245 WorkerChannel channel, - - 2460 postError(ex); + + 246 void Function(dynamic) post, - - 2470 onDone(); + + 247 void Function(Object exception, [StackTrace? stackTrace]) postError, - 248 } + 248 SquadronCancelationToken? token, - - 2490 return (ex == null); + + 249 ) { - - 2500 }; + + 2501 late final StreamSubscription subscription; - - 251 } + + 2515 final done = Completer(); 252 - - 253 // register stream canceler callback and connect stream with client + + 2531 late final int streamId; - - 2546 streamId = _registerStreamCanceler(onDone); + + 254 - - 2556 post(streamId); + + 255 // send endOfStream to client - 2566 if (checkToken()) { + 2566 Future<void> onDone() async { - - 257 // start forwarding messages to the client + + 2576 _unregisterStreamCanceler(streamId); - 2586 subscription = stream.listen( + 2586 channel.closeStream(); - 2596 (data) { + 2596 await subscription.cancel(); - 26011 if (checkToken()) post(data); + 2606 done.complete(); - 2611 }, + 2611 } - - 2624 onError: (ex, st) { + + 262 - - 2636 if (checkToken()) postError(ex, st); + + 263 final bool Function() checkToken; - - 2640 }, + + 264 if (token == null) { - - 265 onDone: onDone, + + 2656 checkToken = () => true; - 266 cancelOnError: false, + 266 } else { - - 267 ); + + 2672 checkToken = () { - - 268 } + + 2682 final ex = token.exception; - - 269 + + 2690 if (ex != null) { - - 2706 return done.future; + + 2700 postError(ex); - - 2711 } + + 2710 onDone(); - 272 + 272 } - - 273 /// Assigns a stream ID to the stream canceler callback and registers the + + 2730 return (ex == null); - - 274 /// callback. + + 2740 }; - - 2755 int _registerStreamCanceler(SquadronCallback canceler) { + + 275 } - - 27610 final streamId = ++_streamId; + + 276 - - 27711 _streamCancelers[streamId] = canceler; + + 277 // register stream canceler callback and connect stream with client - - 278 return streamId; + + 2786 streamId = _registerStreamCanceler(onDone); - - 279 } + + 2796 post(streamId); - - 280 + + 2806 if (checkToken()) { - 281 /// Unregisters the stream canceled callback associated to the [streamId]. + 281 // start forwarding messages to the client - 2825 void _unregisterStreamCanceler(int streamId) { + 2826 subscription = stream.listen( - 28311 _streamCancelers.remove(streamId); + 2836 (data) { - - 284 } + + 28411 if (checkToken()) post(data); - - 285 + + 2851 }, - - 286 /// Terminates the worker if there is no pending execution. Otherwise, marks + + 2864 onError: (ex, st) { - - 287 /// the worker as terminating and termination will be effective when all + + 2876 if (checkToken()) postError(ex, st); - - 288 /// pending executions have completed. + + 2880 }, - - 2899 void _shutdown() { + + 289 onDone: onDone, - - 2909 _terminationRequested = true; + + 290 cancelOnError: false, - - 29118 if (_executing == 0) { + + 291 ); - - 2928 _unmount(); + + 292 } - 293 } + 293 - - 294 } + + 2946 return done.future; - - 295 + + 2951 } - 296 // should not throw + 296 - - 2979 void _unmount() async { + + 297 /// Assigns a stream ID to the stream canceler callback and registers the - - 2980 try { + + 298 /// callback. - - 299 // uninstall the service if necessary + + 2995 int _registerStreamCanceler(SquadronCallback canceler) { - 30010 await _installer?.uninstall(); + 30010 final streamId = ++_streamId; - - 301 } catch (ex) { + + 30111 _streamCancelers[streamId] = canceler; - - 3023 internalLogger.e('Service uninstallation failed with error: $ex'); + + 302 return streamId; - 303 } finally { + 303 } - - 3049 _exit(); + + 304 - 305 } + 305 /// Unregisters the stream canceled callback associated to the [streamId]. - - 3060 } + + 3065 void _unregisterStreamCanceler(int streamId) { - - 307 + + 30711 _streamCancelers.remove(streamId); - 308 // should not throw + 308 } - - 3099 void _exit() { + + 309 - - 3100 try { + + 310 /// Terminates the worker if there is no pending execution. Otherwise, marks - - 31118 _terminate(this); + + 311 /// the worker as terminating and termination will be effective when all - 312 } catch (ex) { + 312 /// pending executions have completed. - - 3130 internalLogger.e('Worker termination failed with error: $ex'); + + 3139 void _shutdown() { - - 314 } + + 3149 _terminationRequested = true; - 3159 if (_logForwarder != null) { + 31518 if (_executing == 0) { - 31618 Logger.removeOutputListener(_logForwarder!); + 3168 _unmount(); 317 } - - 3180 } + + 318 } - 319} + 319 + + + 320 // should not throw + + + 3219 void _unmount() async { + + + 3220 try { + + + 323 // uninstall the service if necessary + + + 32418 if (_service is ServiceInstaller) { + + + 325 // check installation result + + + 3261 final pendingInstallation = _installCompleter?.future; + + + 327 if (pendingInstallation != null) { + + + 328 await pendingInstallation; + + + 3290 _installCompleter = null; + + + 330 } + + + 3311 if (_installResult == null) { + + + 332 // uninstall iif the service installed succesfuly + + + 3332 await (_service as ServiceInstaller).uninstall(); + + + 334 } + + + 335 } + + + 336 } catch (ex) { + + + 3373 internalLogger.e('Service uninstallation failed with error: $ex'); + + + 338 } finally { + + + 3399 _exit(); + + + 340 } + + + 3410 } + + + 342 + + + 343 // should not throw + + + 3449 void _exit() { + + + 3450 try { + + + 34618 _terminate(this); + + + 347 } catch (ex) { + + + 3480 internalLogger.e('Worker termination failed with error: $ex'); + + + 349 } + + + 3509 if (_logForwarder != null) { + + + 35118 Logger.removeOutputListener(_logForwarder!); + + + 352 } + + + 3530 } + + + 354} diff --git a/doc/coverage/html/src/_impl/xplat/index.html b/doc/coverage/html/src/_impl/xplat/index.html index 48e5130a..6ee1e78a 100644 --- a/doc/coverage/html/src/_impl/xplat/index.html +++ b/doc/coverage/html/src/_impl/xplat/index.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
@@ -39,7 +39,7 @@

LCOV - code coverage report

- Lines27535178.3% + Lines28736878.0% Functions00- @@ -127,11 +127,11 @@

LCOV - code coverage report

_worker_runner.dart - 85.0% - 85.0%125/147-0/0-0/0 + 83.5% + 83.5%137/164-0/0-0/0 - <unnamed>85.0%125/147-0/0-0/0 + <unnamed>83.5%137/164-0/0-0/0 diff --git a/doc/coverage/html/src/annotations/index.html b/doc/coverage/html/src/annotations/index.html index b4122319..a7eca44d 100644 --- a/doc/coverage/html/src/annotations/index.html +++ b/doc/coverage/html/src/annotations/index.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
@@ -39,7 +39,7 @@

LCOV - code coverage report

- Lines1911.1% + Lines21020.0% Functions00- @@ -71,8 +71,16 @@

LCOV - code coverage report

squadron_service.dart + 16.7% + 16.7%1/6-0/0-0/0 + + + <unnamed>16.7%1/6-0/0-0/0 + + + target_platform.dart 0.0% - 0.0%0/8-0/0-0/0 + 0.0%0/3-0/0-0/0 diff --git a/doc/coverage/html/src/annotations/squadron_method.dart.gcov.html b/doc/coverage/html/src/annotations/squadron_method.dart.gcov.html index 4bd5820e..f5905742 100644 --- a/doc/coverage/html/src/annotations/squadron_method.dart.gcov.html +++ b/doc/coverage/html/src/annotations/squadron_method.dart.gcov.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
diff --git a/doc/coverage/html/src/annotations/squadron_service.dart.gcov.html b/doc/coverage/html/src/annotations/squadron_service.dart.gcov.html index 82ec7646..b5d29817 100644 --- a/doc/coverage/html/src/annotations/squadron_service.dart.gcov.html +++ b/doc/coverage/html/src/annotations/squadron_service.dart.gcov.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
@@ -40,7 +40,7 @@

LCOV - code coverage report

- Lines080.0% + Lines1616.7% Functions00- @@ -64,127 +64,124 @@

LCOV - code coverage report

1import '../pool/worker_pool.dart'; - 2 + 2import 'target_platform.dart'; - 3/// Annotation for service classes to be wrapped as workers. + 3 - 4class SquadronService { + 4const localService = SquadronService.local(); - - 50 const SquadronService({ + + 5 - 6 this.pool = true, + 6/// Annotation for service classes to be wrapped as workers. - 7 this.targetPlatform = TargetPlatform.all, + 7class SquadronService { - - 8 String? baseUrl, + + 80 const SquadronService({ - 9 }) : baseUrl = baseUrl ?? ''; + 9 this.pool = true, - 10 + 10 this.targetPlatform = TargetPlatform.all, - - 110 const SquadronService.web({bool pool = true, String? baseUrl}) + + 11 String? baseUrl, - - 120 : this(pool: pool, targetPlatform: TargetPlatform.web, baseUrl: baseUrl); + + 12 }) : baseUrl = baseUrl ?? '', - 13 + 13 local = false; - - 140 const SquadronService.vm({bool pool = true}) + + 14 - 150 : this(pool: pool, targetPlatform: TargetPlatform.vm); + 150 const SquadronService.web({bool pool = true, String? baseUrl}) - - 16 + + 160 : this(pool: pool, targetPlatform: TargetPlatform.web, baseUrl: baseUrl); - 17 /// Controls code generation of a [WorkerPool] exposing the target service class. + 17 - - 18 /// `true` by default. + + 180 const SquadronService.vm({bool pool = true}) - - 19 final bool pool; + + 190 : this(pool: pool, targetPlatform: TargetPlatform.vm); 20 - - 21 /// Controls code generation of a entry points for various platforms. + + 2111 const SquadronService.local() - 22 final int targetPlatform; + 22 : pool = false, - 23 + 23 local = true, - 24 /// For Web-based workers, indicates the [baseUrl] where the Web Worker will + 24 targetPlatform = TargetPlatform.all, - 25 /// be exposed in production. + 25 baseUrl = ''; - 26 final String baseUrl; + 26 - 27} + 27 /// Controls code generation of a [WorkerPool] exposing the target service class. - 28 + 28 /// `true` by default. - 29final class TargetPlatform { + 29 final bool pool; - 30 static const vm = 1; + 30 - 31 static const js = 2; + 31 /// Controls code generation of a [LocalWorkerClient] exposing the target service class. - 32 static const wasm = 4; + 32 /// `false` by default. - 33 + 33 final bool local; - 34 static const web = js | wasm; + 34 - 35 static const all = vm | js | wasm; + 35 /// Controls code generation of a entry points for various platforms. - 36} + 36 final int targetPlatform; 37 - 38extension TargetPlatformExt on int { + 38 /// For Web-based workers, indicates the [baseUrl] where the Web Worker will - - 390 bool get hasVm => (this & TargetPlatform.vm) != 0; + + 39 /// be exposed in production. - - 400 bool get hasJs => (this & TargetPlatform.js) != 0; + + 40 final String baseUrl; - - 410 bool get hasWasm => (this & TargetPlatform.wasm) != 0; - - - 42} + + 41} diff --git a/doc/coverage/html/src/annotations/target_platform.dart.gcov.html b/doc/coverage/html/src/annotations/target_platform.dart.gcov.html new file mode 100644 index 00000000..117fe9a9 --- /dev/null +++ b/doc/coverage/html/src/annotations/target_platform.dart.gcov.html @@ -0,0 +1,118 @@ + + + + + + + LCOV - lcov.info target_platform.dart + + +

LCOV - code coverage report

+
+
+
+
Current view
+
+ top level - src/annotations - target_platform.dart +
+
Test
+
lcov.info
+
Date
+
2024-10-20
+
Legend
+
+
+
Lines
+
hit
+
not hit
+
Branches
+
taken
+
not taken
+
# not executed
+
+
+
+ + + + + + + + + + + + + + + + + +
HitTotalCoverage
Lines030.0%
Functions00-
Branches00-
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Each row represents a line of source code
LineBranchHitsSource code
1final class TargetPlatform {
2 static const vm = 1;
3 static const js = 2;
4 static const wasm = 4;
5
6 static const web = js | wasm;
7 static const all = vm | js | wasm;
8}
9
10extension TargetPlatformExt on int {
110 bool get hasVm => (this & TargetPlatform.vm) != 0;
120 bool get hasJs => (this & TargetPlatform.js) != 0;
130 bool get hasWasm => (this & TargetPlatform.wasm) != 0;
14}
+ +
+
+ Choose Features +
+
+ + diff --git a/doc/coverage/html/src/bootstrapper.dart.gcov.html b/doc/coverage/html/src/bootstrapper.dart.gcov.html index b162da77..41527f1c 100644 --- a/doc/coverage/html/src/bootstrapper.dart.gcov.html +++ b/doc/coverage/html/src/bootstrapper.dart.gcov.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
diff --git a/doc/coverage/html/src/channel.dart.gcov.html b/doc/coverage/html/src/channel.dart.gcov.html index 096368ee..57c59671 100644 --- a/doc/coverage/html/src/channel.dart.gcov.html +++ b/doc/coverage/html/src/channel.dart.gcov.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
diff --git a/doc/coverage/html/src/concurrency_settings.dart.gcov.html b/doc/coverage/html/src/concurrency_settings.dart.gcov.html index 9cebb60a..c14f335a 100644 --- a/doc/coverage/html/src/concurrency_settings.dart.gcov.html +++ b/doc/coverage/html/src/concurrency_settings.dart.gcov.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
diff --git a/doc/coverage/html/src/converters/cast_converter.dart.gcov.html b/doc/coverage/html/src/converters/cast_converter.dart.gcov.html index 3ff04d7c..b8cf5c1d 100644 --- a/doc/coverage/html/src/converters/cast_converter.dart.gcov.html +++ b/doc/coverage/html/src/converters/cast_converter.dart.gcov.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
diff --git a/doc/coverage/html/src/converters/converter.dart.gcov.html b/doc/coverage/html/src/converters/converter.dart.gcov.html index ee6d0906..5ee73867 100644 --- a/doc/coverage/html/src/converters/converter.dart.gcov.html +++ b/doc/coverage/html/src/converters/converter.dart.gcov.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
diff --git a/doc/coverage/html/src/converters/direct_cast_converter.dart.gcov.html b/doc/coverage/html/src/converters/direct_cast_converter.dart.gcov.html index b0165906..5c5e92bb 100644 --- a/doc/coverage/html/src/converters/direct_cast_converter.dart.gcov.html +++ b/doc/coverage/html/src/converters/direct_cast_converter.dart.gcov.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
diff --git a/doc/coverage/html/src/converters/in_place_converter.dart.gcov.html b/doc/coverage/html/src/converters/in_place_converter.dart.gcov.html index ec1de997..a886824b 100644 --- a/doc/coverage/html/src/converters/in_place_converter.dart.gcov.html +++ b/doc/coverage/html/src/converters/in_place_converter.dart.gcov.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
diff --git a/doc/coverage/html/src/converters/index.html b/doc/coverage/html/src/converters/index.html index 80b398b8..cde3402b 100644 --- a/doc/coverage/html/src/converters/index.html +++ b/doc/coverage/html/src/converters/index.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
diff --git a/doc/coverage/html/src/converters/lazy_in_place_converter.dart.gcov.html b/doc/coverage/html/src/converters/lazy_in_place_converter.dart.gcov.html index ffa4bf6d..79696dc8 100644 --- a/doc/coverage/html/src/converters/lazy_in_place_converter.dart.gcov.html +++ b/doc/coverage/html/src/converters/lazy_in_place_converter.dart.gcov.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
diff --git a/doc/coverage/html/src/converters/lazy_in_place_list.dart.gcov.html b/doc/coverage/html/src/converters/lazy_in_place_list.dart.gcov.html index 46aa2276..6308d09e 100644 --- a/doc/coverage/html/src/converters/lazy_in_place_list.dart.gcov.html +++ b/doc/coverage/html/src/converters/lazy_in_place_list.dart.gcov.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
diff --git a/doc/coverage/html/src/converters/lazy_in_place_map.dart.gcov.html b/doc/coverage/html/src/converters/lazy_in_place_map.dart.gcov.html index a3ebccde..3c2f6c94 100644 --- a/doc/coverage/html/src/converters/lazy_in_place_map.dart.gcov.html +++ b/doc/coverage/html/src/converters/lazy_in_place_map.dart.gcov.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
diff --git a/doc/coverage/html/src/converters/num_converter.dart.gcov.html b/doc/coverage/html/src/converters/num_converter.dart.gcov.html index 00b94ba6..557c9240 100644 --- a/doc/coverage/html/src/converters/num_converter.dart.gcov.html +++ b/doc/coverage/html/src/converters/num_converter.dart.gcov.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
diff --git a/doc/coverage/html/src/exceptions/_well_known_exceptions.dart.gcov.html b/doc/coverage/html/src/exceptions/_well_known_exceptions.dart.gcov.html index 74384ab6..4e7b50b1 100644 --- a/doc/coverage/html/src/exceptions/_well_known_exceptions.dart.gcov.html +++ b/doc/coverage/html/src/exceptions/_well_known_exceptions.dart.gcov.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
diff --git a/doc/coverage/html/src/exceptions/exception_manager.dart.gcov.html b/doc/coverage/html/src/exceptions/exception_manager.dart.gcov.html index c1159e88..1297378e 100644 --- a/doc/coverage/html/src/exceptions/exception_manager.dart.gcov.html +++ b/doc/coverage/html/src/exceptions/exception_manager.dart.gcov.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
@@ -217,13 +217,13 @@

LCOV - code coverage report

52 /// Deserializes a [List] that was produced by [serialize]. - 5320 SquadronException? deserialize(List? data) { + 5321 SquadronException? deserialize(List? data) { - 5416 if (data == null || data.isEmpty) { + 5417 if (data == null || data.isEmpty) { - 559 return null; + 5510 return null; 56 } @@ -259,7 +259,7 @@

LCOV - code coverage report

66 } - 6711 } + 6712 } 68} diff --git a/doc/coverage/html/src/exceptions/index.html b/doc/coverage/html/src/exceptions/index.html index 930edf46..67e3231d 100644 --- a/doc/coverage/html/src/exceptions/index.html +++ b/doc/coverage/html/src/exceptions/index.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
diff --git a/doc/coverage/html/src/exceptions/squadron_canceled_exception.dart.gcov.html b/doc/coverage/html/src/exceptions/squadron_canceled_exception.dart.gcov.html index ad94d025..238660b6 100644 --- a/doc/coverage/html/src/exceptions/squadron_canceled_exception.dart.gcov.html +++ b/doc/coverage/html/src/exceptions/squadron_canceled_exception.dart.gcov.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
diff --git a/doc/coverage/html/src/exceptions/squadron_canceled_exceptions.dart.gcov.html b/doc/coverage/html/src/exceptions/squadron_canceled_exceptions.dart.gcov.html index 71818f41..917d31b6 100644 --- a/doc/coverage/html/src/exceptions/squadron_canceled_exceptions.dart.gcov.html +++ b/doc/coverage/html/src/exceptions/squadron_canceled_exceptions.dart.gcov.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
diff --git a/doc/coverage/html/src/exceptions/squadron_error.dart.gcov.html b/doc/coverage/html/src/exceptions/squadron_error.dart.gcov.html index d507e4fa..18904699 100644 --- a/doc/coverage/html/src/exceptions/squadron_error.dart.gcov.html +++ b/doc/coverage/html/src/exceptions/squadron_error.dart.gcov.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
@@ -133,7 +133,7 @@

LCOV - code coverage report

2410 static SquadronError create(String message, [StackTrace? stackTrace]) => - 2516 SquadronError._(message, stackTrace); + 2515 SquadronError._(message, stackTrace); 26 diff --git a/doc/coverage/html/src/exceptions/squadron_exception.dart.gcov.html b/doc/coverage/html/src/exceptions/squadron_exception.dart.gcov.html index 369eeb88..ca53a631 100644 --- a/doc/coverage/html/src/exceptions/squadron_exception.dart.gcov.html +++ b/doc/coverage/html/src/exceptions/squadron_exception.dart.gcov.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
@@ -91,10 +91,10 @@

LCOV - code coverage report

10abstract class SquadronException implements Exception { - 1119 SquadronException.init(this.message, [this._stackTrace]) { + 1120 SquadronException.init(this.message, [this._stackTrace]) { - 1219 if (_stackTrace == null) { + 1220 if (_stackTrace == null) { 13 try { @@ -118,7 +118,7 @@

LCOV - code coverage report

19 } - 209 } + 2010 } 21 @@ -133,13 +133,13 @@

LCOV - code coverage report

24 /// [WorkerException] wrapping [error] and [stackTrace]. - 2515 static SquadronException from(Object error, + 2516 static SquadronException from(Object error, 26 [StackTrace? stackTrace, int? command]) { - 2715 if (error is WorkerException) { + 2716 if (error is WorkerException) { 289 if (command != null) error.setCommand(command); @@ -175,7 +175,7 @@

LCOV - code coverage report

38 } - 398 } + 399 } 40 diff --git a/doc/coverage/html/src/exceptions/squadron_timeout_exception.dart.gcov.html b/doc/coverage/html/src/exceptions/squadron_timeout_exception.dart.gcov.html index 50df754f..252b45cd 100644 --- a/doc/coverage/html/src/exceptions/squadron_timeout_exception.dart.gcov.html +++ b/doc/coverage/html/src/exceptions/squadron_timeout_exception.dart.gcov.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
diff --git a/doc/coverage/html/src/exceptions/task_canceled_exception.dart.gcov.html b/doc/coverage/html/src/exceptions/task_canceled_exception.dart.gcov.html index 858d8cc8..23e7ee26 100644 --- a/doc/coverage/html/src/exceptions/task_canceled_exception.dart.gcov.html +++ b/doc/coverage/html/src/exceptions/task_canceled_exception.dart.gcov.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
diff --git a/doc/coverage/html/src/exceptions/worker_exception.dart.gcov.html b/doc/coverage/html/src/exceptions/worker_exception.dart.gcov.html index fe9f8fec..a17d9c67 100644 --- a/doc/coverage/html/src/exceptions/worker_exception.dart.gcov.html +++ b/doc/coverage/html/src/exceptions/worker_exception.dart.gcov.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
diff --git a/doc/coverage/html/src/index.html b/doc/coverage/html/src/index.html index fb7c7bc4..7c4f8bd7 100644 --- a/doc/coverage/html/src/index.html +++ b/doc/coverage/html/src/index.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
diff --git a/doc/coverage/html/src/local_worker/index.html b/doc/coverage/html/src/local_worker/index.html index a2da87bf..60e393b3 100644 --- a/doc/coverage/html/src/local_worker/index.html +++ b/doc/coverage/html/src/local_worker/index.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
@@ -39,7 +39,7 @@

LCOV - code coverage report

- Lines152365.2% + Lines162466.7% Functions00- @@ -71,11 +71,11 @@

LCOV - code coverage report

local_worker.dart - 76.9% - 76.9%10/13-0/0-0/0 + 78.6% + 78.6%11/14-0/0-0/0 - <unnamed>76.9%10/13-0/0-0/0 + <unnamed>78.6%11/14-0/0-0/0 diff --git a/doc/coverage/html/src/local_worker/local_worker.dart.gcov.html b/doc/coverage/html/src/local_worker/local_worker.dart.gcov.html index 75947ec4..7059014a 100644 --- a/doc/coverage/html/src/local_worker/local_worker.dart.gcov.html +++ b/doc/coverage/html/src/local_worker/local_worker.dart.gcov.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
@@ -40,7 +40,7 @@

LCOV - code coverage report

- Lines101376.9% + Lines111478.6% Functions00- @@ -148,7 +148,7 @@

LCOV - code coverage report

29/// worker are deserialized as [WorkerRequest]s and dispatched to a handler - 30/// defined in the [service]'s [WorkerService.operations] map according to the + 30/// defined in the [_service]'s [WorkerService.operations] map according to the 31/// [WorkerRequest.command]. @@ -163,7 +163,7 @@

LCOV - code coverage report

34 implements WorkerService, IWorker { - 351 LocalWorker(this.service); + 351 LocalWorker(this._service); 36 @@ -181,7 +181,7 @@

LCOV - code coverage report

40 - 41 final W service; + 41 final W _service; 42 @@ -274,13 +274,13 @@

LCOV - code coverage report

71 - 72 /// Local Workers do not need an [operations] map. + 72 /// Forward to underlying service. - - 73 @override + + 731 @override - 741 final Map<int, CommandHandler> operations = WorkerService.noOperations; + 743 Map<int, CommandHandler> get operations => _service.operations; 75} diff --git a/doc/coverage/html/src/local_worker/local_worker_client.dart.gcov.html b/doc/coverage/html/src/local_worker/local_worker_client.dart.gcov.html index dbcca3eb..f37c6dcf 100644 --- a/doc/coverage/html/src/local_worker/local_worker_client.dart.gcov.html +++ b/doc/coverage/html/src/local_worker/local_worker_client.dart.gcov.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
@@ -154,7 +154,7 @@

LCOV - code coverage report

31 {List args = const [], - 32 SquadronCancelationToken? token, + 32 CancelationToken? token, 33 bool inspectRequest = false, diff --git a/doc/coverage/html/src/marshalers/generic_marshaler.dart.gcov.html b/doc/coverage/html/src/marshalers/generic_marshaler.dart.gcov.html index e4d0c00c..740501d4 100644 --- a/doc/coverage/html/src/marshalers/generic_marshaler.dart.gcov.html +++ b/doc/coverage/html/src/marshalers/generic_marshaler.dart.gcov.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
diff --git a/doc/coverage/html/src/marshalers/identity_marshaler.dart.gcov.html b/doc/coverage/html/src/marshalers/identity_marshaler.dart.gcov.html index 6c7060d4..605fb6b0 100644 --- a/doc/coverage/html/src/marshalers/identity_marshaler.dart.gcov.html +++ b/doc/coverage/html/src/marshalers/identity_marshaler.dart.gcov.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
diff --git a/doc/coverage/html/src/marshalers/index.html b/doc/coverage/html/src/marshalers/index.html index def810ff..c52d0953 100644 --- a/doc/coverage/html/src/marshalers/index.html +++ b/doc/coverage/html/src/marshalers/index.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
diff --git a/doc/coverage/html/src/marshalers/squadron_marshaler.dart.gcov.html b/doc/coverage/html/src/marshalers/squadron_marshaler.dart.gcov.html index 79802afc..48d98154 100644 --- a/doc/coverage/html/src/marshalers/squadron_marshaler.dart.gcov.html +++ b/doc/coverage/html/src/marshalers/squadron_marshaler.dart.gcov.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
diff --git a/doc/coverage/html/src/pool/_pool_worker.dart.gcov.html b/doc/coverage/html/src/pool/_pool_worker.dart.gcov.html index c21df25c..5222d8fd 100644 --- a/doc/coverage/html/src/pool/_pool_worker.dart.gcov.html +++ b/doc/coverage/html/src/pool/_pool_worker.dart.gcov.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
diff --git a/doc/coverage/html/src/pool/_worker_stream_task.dart.gcov.html b/doc/coverage/html/src/pool/_worker_stream_task.dart.gcov.html index dff50234..c252470d 100644 --- a/doc/coverage/html/src/pool/_worker_stream_task.dart.gcov.html +++ b/doc/coverage/html/src/pool/_worker_stream_task.dart.gcov.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
@@ -178,7 +178,7 @@

LCOV - code coverage report

39 - 404 late final ForwardStreamController<T> _controller; + 405 late final ForwardStreamController<T> _controller; 41 @@ -208,13 +208,13 @@

LCOV - code coverage report

49 - 5016 void _onData(T data) => _controller.add(data); + 5017 void _onData(T data) => _controller.add(data); 51 - 5215 void _onError(ex, st) => _controller.addError(SquadronException.from(ex, st)); + 5216 void _onError(ex, st) => _controller.addError(SquadronException.from(ex, st)); 53 diff --git a/doc/coverage/html/src/pool/_worker_task.dart.gcov.html b/doc/coverage/html/src/pool/_worker_task.dart.gcov.html index ce15148d..413f8a91 100644 --- a/doc/coverage/html/src/pool/_worker_task.dart.gcov.html +++ b/doc/coverage/html/src/pool/_worker_task.dart.gcov.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
diff --git a/doc/coverage/html/src/pool/_worker_value_task.dart.gcov.html b/doc/coverage/html/src/pool/_worker_value_task.dart.gcov.html index ddd257c0..6d1ca978 100644 --- a/doc/coverage/html/src/pool/_worker_value_task.dart.gcov.html +++ b/doc/coverage/html/src/pool/_worker_value_task.dart.gcov.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
diff --git a/doc/coverage/html/src/pool/index.html b/doc/coverage/html/src/pool/index.html index 4cb6861a..b9e5c230 100644 --- a/doc/coverage/html/src/pool/index.html +++ b/doc/coverage/html/src/pool/index.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
diff --git a/doc/coverage/html/src/pool/worker_pool.dart.gcov.html b/doc/coverage/html/src/pool/worker_pool.dart.gcov.html index 660d9a2c..dfa42aa8 100644 --- a/doc/coverage/html/src/pool/worker_pool.dart.gcov.html +++ b/doc/coverage/html/src/pool/worker_pool.dart.gcov.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
diff --git a/doc/coverage/html/src/squadron_platform_type.dart.gcov.html b/doc/coverage/html/src/squadron_platform_type.dart.gcov.html index 8e286c40..794620cb 100644 --- a/doc/coverage/html/src/squadron_platform_type.dart.gcov.html +++ b/doc/coverage/html/src/squadron_platform_type.dart.gcov.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
diff --git a/doc/coverage/html/src/squadron_singleton.dart.gcov.html b/doc/coverage/html/src/squadron_singleton.dart.gcov.html index 4d62e8a0..9f94c646 100644 --- a/doc/coverage/html/src/squadron_singleton.dart.gcov.html +++ b/doc/coverage/html/src/squadron_singleton.dart.gcov.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
diff --git a/doc/coverage/html/src/stats/index.html b/doc/coverage/html/src/stats/index.html index b4ada144..d0644379 100644 --- a/doc/coverage/html/src/stats/index.html +++ b/doc/coverage/html/src/stats/index.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
diff --git a/doc/coverage/html/src/stats/perf_counter.dart.gcov.html b/doc/coverage/html/src/stats/perf_counter.dart.gcov.html index 47a91477..32c8cc6b 100644 --- a/doc/coverage/html/src/stats/perf_counter.dart.gcov.html +++ b/doc/coverage/html/src/stats/perf_counter.dart.gcov.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
diff --git a/doc/coverage/html/src/stats/perf_counter_snapshot.dart.gcov.html b/doc/coverage/html/src/stats/perf_counter_snapshot.dart.gcov.html index 4cc3c1e2..242c7a69 100644 --- a/doc/coverage/html/src/stats/perf_counter_snapshot.dart.gcov.html +++ b/doc/coverage/html/src/stats/perf_counter_snapshot.dart.gcov.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
diff --git a/doc/coverage/html/src/stats/worker_stat.dart.gcov.html b/doc/coverage/html/src/stats/worker_stat.dart.gcov.html index 472d8c18..3e95337f 100644 --- a/doc/coverage/html/src/stats/worker_stat.dart.gcov.html +++ b/doc/coverage/html/src/stats/worker_stat.dart.gcov.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
diff --git a/doc/coverage/html/src/tokens/_cancelation_token_ref.dart.gcov.html b/doc/coverage/html/src/tokens/_cancelation_token_ref.dart.gcov.html index 0bd1f485..e3ce4c6c 100644 --- a/doc/coverage/html/src/tokens/_cancelation_token_ref.dart.gcov.html +++ b/doc/coverage/html/src/tokens/_cancelation_token_ref.dart.gcov.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
diff --git a/doc/coverage/html/src/tokens/_squadron_cancelation_token.dart.gcov.html b/doc/coverage/html/src/tokens/_squadron_cancelation_token.dart.gcov.html index 836e2ca1..8787b172 100644 --- a/doc/coverage/html/src/tokens/_squadron_cancelation_token.dart.gcov.html +++ b/doc/coverage/html/src/tokens/_squadron_cancelation_token.dart.gcov.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
diff --git a/doc/coverage/html/src/tokens/index.html b/doc/coverage/html/src/tokens/index.html index 763e721a..53a5070e 100644 --- a/doc/coverage/html/src/tokens/index.html +++ b/doc/coverage/html/src/tokens/index.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
diff --git a/doc/coverage/html/src/typedefs.dart.gcov.html b/doc/coverage/html/src/typedefs.dart.gcov.html index 23287935..f524d7d8 100644 --- a/doc/coverage/html/src/typedefs.dart.gcov.html +++ b/doc/coverage/html/src/typedefs.dart.gcov.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
diff --git a/doc/coverage/html/src/worker/index.html b/doc/coverage/html/src/worker/index.html index c4e6834a..035f92ca 100644 --- a/doc/coverage/html/src/worker/index.html +++ b/doc/coverage/html/src/worker/index.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
diff --git a/doc/coverage/html/src/worker/worker.dart.gcov.html b/doc/coverage/html/src/worker/worker.dart.gcov.html index 62f2bf31..cbcef3c3 100644 --- a/doc/coverage/html/src/worker/worker.dart.gcov.html +++ b/doc/coverage/html/src/worker/worker.dart.gcov.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
diff --git a/doc/coverage/html/src/worker/worker_channel.dart.gcov.html b/doc/coverage/html/src/worker/worker_channel.dart.gcov.html index c564354c..e01a730a 100644 --- a/doc/coverage/html/src/worker/worker_channel.dart.gcov.html +++ b/doc/coverage/html/src/worker/worker_channel.dart.gcov.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
diff --git a/doc/coverage/html/src/worker/worker_message.dart.gcov.html b/doc/coverage/html/src/worker/worker_message.dart.gcov.html index 6bfb4368..40ff9f4a 100644 --- a/doc/coverage/html/src/worker/worker_message.dart.gcov.html +++ b/doc/coverage/html/src/worker/worker_message.dart.gcov.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
@@ -112,13 +112,13 @@

LCOV - code coverage report

1710 void unwrapTravelTime() { - 1829 final ts = (data[_$traveltime] as num?)?.toInt(); + 1830 final ts = (data[_$traveltime] as num?)?.toInt(); - 1911 if (ts != null) { + 1912 if (ts != null) { - 2038 data[_$traveltime] = microsecTimeStamp() - ts; + 2039 data[_$traveltime] = microsecTimeStamp() - ts; 21 } diff --git a/doc/coverage/html/src/worker/worker_request.dart.gcov.html b/doc/coverage/html/src/worker/worker_request.dart.gcov.html index 149d25f2..c7f32358 100644 --- a/doc/coverage/html/src/worker/worker_request.dart.gcov.html +++ b/doc/coverage/html/src/worker/worker_request.dart.gcov.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
diff --git a/doc/coverage/html/src/worker/worker_response.dart.gcov.html b/doc/coverage/html/src/worker/worker_response.dart.gcov.html index 6265b8bd..49d82c4e 100644 --- a/doc/coverage/html/src/worker/worker_response.dart.gcov.html +++ b/doc/coverage/html/src/worker/worker_response.dart.gcov.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
@@ -238,10 +238,10 @@

LCOV - code coverage report

59 /// Special [WorkerResponse] message to indicate the end of a stream. - 6015 static WorkerResponse closeStream() => WorkerResponse._([ + 6018 static WorkerResponse closeStream() => WorkerResponse._([ - 616 microsecTimeStamp(), // 0 - travel time + 617 microsecTimeStamp(), // 0 - travel time 62 null, // 1 - result @@ -265,7 +265,7 @@

LCOV - code coverage report

68 /// Flag indicating the end of the [Stream]ing operation. - 6915 bool get endOfStream => data[_$endOfStream]; + 6928 bool get endOfStream => data[_$endOfStream]; 70 @@ -274,7 +274,7 @@

LCOV - code coverage report

71 /// The [WorkerResponse] exception, if any. - 7229 SquadronException? get error => data[_$error]; + 7230 SquadronException? get error => data[_$error]; 73 @@ -286,13 +286,13 @@

LCOV - code coverage report

75 /// [WorkerResponse] contains an error, an the [error] exception is thrown. - 7619 dynamic get result { + 7620 dynamic get result { 779 final err = error; - 7810 if (err != null) { + 7811 if (err != null) { 790 throw err; @@ -301,13 +301,13 @@

LCOV - code coverage report

80 } else { - 8119 return data[_$result]; + 8120 return data[_$result]; 82 } - 8310 } + 8311 } 84} @@ -349,16 +349,16 @@

LCOV - code coverage report

96 /// used for log messages only). - 9720 bool unwrapInPlace(Channel channel) { + 9721 bool unwrapInPlace(Channel channel) { 9810 unwrapTravelTime(); - 9929 final log = _LogEventSerializationExt.deserialize(data[_$log]); + 9930 final log = _LogEventSerializationExt.deserialize(data[_$log]); - 10011 if (log != null) { + 10012 if (log != null) { 10124 channel.logger?.log(log.level, log.message, @@ -373,19 +373,19 @@

LCOV - code coverage report

104 } else { - 10547 data[_$error] = channel.exceptionManager.deserialize(data[_$error]); + 10548 data[_$error] = channel.exceptionManager.deserialize(data[_$error]); - 10620 data[_$endOfStream] ??= false; + 10621 data[_$endOfStream] ??= false; - 10711 return true; + 10712 return true; 108 } - 10911 } + 10912 } 110 @@ -421,10 +421,10 @@

LCOV - code coverage report

120 - 12120 static WorkerResponse from(List data) { + 12121 static WorkerResponse from(List data) { - 12229 if (data.length != 5) { + 12230 if (data.length != 5) { 1230 throw SquadronErrorExt.create('Invalid worker response'); @@ -433,10 +433,10 @@

LCOV - code coverage report

124 } - 12520 return WorkerResponse._(data); + 12521 return WorkerResponse._(data); - 12611 } + 12612 } 127} diff --git a/doc/coverage/html/src/worker_service.dart.gcov.html b/doc/coverage/html/src/worker_service.dart.gcov.html index c85be348..558fbbf6 100644 --- a/doc/coverage/html/src/worker_service.dart.gcov.html +++ b/doc/coverage/html/src/worker_service.dart.gcov.html @@ -18,7 +18,7 @@

LCOV - code coverage report

Test
lcov.info
Date
-
2024-09-24
+
2024-10-20
Legend
@@ -178,10 +178,10 @@

LCOV - code coverage report

39 /// Empty command handlers map. - 403 static final Map<int, CommandHandler> noOperations = + 402 static final Map<int, CommandHandler> noOperations = - 412 Map<int, CommandHandler>.unmodifiable(const {}); + 411 Map<int, CommandHandler>.unmodifiable(const {}); 42} diff --git a/doc/coverage/xml/index.xml b/doc/coverage/xml/index.xml index cf525d62..468abbec 100644 --- a/doc/coverage/xml/index.xml +++ b/doc/coverage/xml/index.xml @@ -1,16 +1,16 @@ - + - + - - + + - + - + diff --git a/doc/coverage/xml/src/_impl/native/_bootstrapper.dart.gcov.xml b/doc/coverage/xml/src/_impl/native/_bootstrapper.dart.gcov.xml index 71050a57..20d8ef12 100644 --- a/doc/coverage/xml/src/_impl/native/_bootstrapper.dart.gcov.xml +++ b/doc/coverage/xml/src/_impl/native/_bootstrapper.dart.gcov.xml @@ -1,5 +1,5 @@ - + import 'dart:isolate'; diff --git a/doc/coverage/xml/src/_impl/native/_channel.dart.gcov.xml b/doc/coverage/xml/src/_impl/native/_channel.dart.gcov.xml index 120af91f..03e69e04 100644 --- a/doc/coverage/xml/src/_impl/native/_channel.dart.gcov.xml +++ b/doc/coverage/xml/src/_impl/native/_channel.dart.gcov.xml @@ -1,5 +1,5 @@ - + import 'dart:async'; @@ -112,333 +112,356 @@ + Channel? channel; + + - + void failure(Object error, [StackTrace? stackTrace]) { - + if (!completer.isCompleted) { - + completer.completeError(SquadronException.from(error, stackTrace)); - + } - + } - + - + void success(Channel channel) { - + if (!completer.isCompleted) { - + completer.complete(channel); - + } - + } - + - + final receiver = vm.ReceivePort(); - + final exitPort = vm.ReceivePort(); - + final errorPort = vm.ReceivePort(); - + - + exitPort.listen((message) { - + failure(SquadronErrorExt.create('Connection to worker failed')); - + logger?.t('Isolate terminated.'); - + + channel?.close(); + + + receiver.close(); - + errorPort.close(); - + exitPort.close(); - + }); - + - + errorPort.listen((message) { - + SquadronException? error; - + try { - + final data = jsonDecode(message[0]); - + if (data is List) { - + error = exceptionManager.deserialize(data.cast<String>()); - + } - + } catch (_) { - + // not a String representing a SquadronException - + } - + - + error ??= WorkerException( - + message[0], - + SquadronException.loadStackTrace(message[1]), - + ); - + - + logger?.d(() => 'Unhandled error from Isolate: ${error?.message}.'); - + failure(error); - + }); - + - + final disconnected = DisconnectedChannel(exceptionManager, logger); - + - + receiver.listen((message) { - + final response = WorkerResponseExt.from(message); - + if (!response.unwrapInPlace(disconnected)) { - + return; - + } - + - + final error = response.error; - + if (error != null) { - + logger?.e(() => 'Connection to Isolate failed: ${response.error}'); - + failure(error); - + + } else if (response.endOfStream) { + + + + logger?.w('Disconnecting from Isolate'); + + + + channel?.close(); + + + } else if (!completer.isCompleted) { - + logger?.t('Connected to Isolate'); - - success(_VmChannel._(response.result, logger, exceptionManager)); - + + channel = _VmChannel._(response.result, logger, exceptionManager); + - + + success(channel!); + + + } else { - + logger?.e(() => 'Unexpected response: $response'); - + } - + }); - + - + final startRequest = WorkerRequest.start(receiver.sendPort, startArguments); - + startRequest.wrapInPlace(); - + final isolate = await vm.Isolate.spawn( - + entryPoint, - + startRequest, - + errorsAreFatal: false, - + onExit: exitPort.sendPort, - + onError: errorPort.sendPort, - + ); - + - + try { - + final channel = await completer.future; - + await hook?.call(isolate); - + logger?.t('Created Isolate'); - + return channel; - + } catch (ex) { - + logger?.e(() => 'Connection to Isolate failed: $ex'); - + isolate.kill(priority: vm.Isolate.beforeNextEvent); - + rethrow; - + } - + } - + - + /// Creates a [_VmChannel] from a [SendPort]. - + Channel? deserialize(PlatformChannel? channelInfo, - + [Logger? logger, ExceptionManager? exceptionManager]) => - + (channelInfo == null) - + ? null - + : _VmChannel._( - + channelInfo, - + logger, - + exceptionManager ?? ExceptionManager(), - + ); diff --git a/doc/coverage/xml/src/_impl/native/_channel_impl.dart.gcov.xml b/doc/coverage/xml/src/_impl/native/_channel_impl.dart.gcov.xml index d2ba7d28..2e4d02a8 100644 --- a/doc/coverage/xml/src/_impl/native/_channel_impl.dart.gcov.xml +++ b/doc/coverage/xml/src/_impl/native/_channel_impl.dart.gcov.xml @@ -1,5 +1,5 @@ - + part of '_channel.dart'; diff --git a/doc/coverage/xml/src/_impl/native/_local_worker.dart.gcov.xml b/doc/coverage/xml/src/_impl/native/_local_worker.dart.gcov.xml index 6fd128c9..cff293af 100644 --- a/doc/coverage/xml/src/_impl/native/_local_worker.dart.gcov.xml +++ b/doc/coverage/xml/src/_impl/native/_local_worker.dart.gcov.xml @@ -1,5 +1,5 @@ - + import 'dart:async'; diff --git a/doc/coverage/xml/src/_impl/native/_platform.dart.gcov.xml b/doc/coverage/xml/src/_impl/native/_platform.dart.gcov.xml index 69056148..e77baaae 100644 --- a/doc/coverage/xml/src/_impl/native/_platform.dart.gcov.xml +++ b/doc/coverage/xml/src/_impl/native/_platform.dart.gcov.xml @@ -1,5 +1,5 @@ - + import '../../converters/converter.dart'; diff --git a/doc/coverage/xml/src/_impl/native/_typedefs.dart.gcov.xml b/doc/coverage/xml/src/_impl/native/_typedefs.dart.gcov.xml index 515f881b..d8144cf7 100644 --- a/doc/coverage/xml/src/_impl/native/_typedefs.dart.gcov.xml +++ b/doc/coverage/xml/src/_impl/native/_typedefs.dart.gcov.xml @@ -1,5 +1,5 @@ - + import 'dart:async'; diff --git a/doc/coverage/xml/src/_impl/native/_worker_channel.dart.gcov.xml b/doc/coverage/xml/src/_impl/native/_worker_channel.dart.gcov.xml index ddf48d1d..7f8b8cbc 100644 --- a/doc/coverage/xml/src/_impl/native/_worker_channel.dart.gcov.xml +++ b/doc/coverage/xml/src/_impl/native/_worker_channel.dart.gcov.xml @@ -1,5 +1,5 @@ - + import 'dart:async'; @@ -194,13 +194,13 @@ /// must be called from the worker [Isolate] only. - + @override - + - + void closeStream() => _postResponse(WorkerResponse.closeStream()); - + diff --git a/doc/coverage/xml/src/_impl/native/_worker_runner.dart.gcov.xml b/doc/coverage/xml/src/_impl/native/_worker_runner.dart.gcov.xml index abd8f47b..3428cd70 100644 --- a/doc/coverage/xml/src/_impl/native/_worker_runner.dart.gcov.xml +++ b/doc/coverage/xml/src/_impl/native/_worker_runner.dart.gcov.xml @@ -1,5 +1,5 @@ - + import '../../worker/worker_request.dart'; diff --git a/doc/coverage/xml/src/_impl/native/index.xml b/doc/coverage/xml/src/_impl/native/index.xml index 11e0d359..861cd25b 100644 --- a/doc/coverage/xml/src/_impl/native/index.xml +++ b/doc/coverage/xml/src/_impl/native/index.xml @@ -1,5 +1,5 @@ - + @@ -16,8 +16,8 @@ - - + + diff --git a/doc/coverage/xml/src/_impl/web/_channel.dart.gcov.xml b/doc/coverage/xml/src/_impl/web/_channel.dart.gcov.xml index f1886cae..c8e355b4 100644 --- a/doc/coverage/xml/src/_impl/web/_channel.dart.gcov.xml +++ b/doc/coverage/xml/src/_impl/web/_channel.dart.gcov.xml @@ -1,5 +1,5 @@ - + import 'dart:async'; @@ -127,469 +127,502 @@ final ready = Completer<bool>(); - + Channel? channel; + + + final com = web.MessageChannel(); - + final webEntryPoint = EntryPointUri.from(entryPoint); - + late web.Worker worker; - + - + void fail(SquadronException ex) { - + if (!ready.isCompleted) ready.completeError(ex); - + if (!completer.isCompleted) completer.completeError(ex); - + } - + - + void success(Channel channel) { - + if (!ready.isCompleted) { - + throw SquadronErrorExt.create('Invalid state: worker is not ready'); - + } - + if (!completer.isCompleted) completer.complete(channel); - + } - + - + try { - + worker = web.Worker(webEntryPoint.uri.toJS); - + - + void $errorHandler(web.ErrorEvent? e) { - + final err = getError(e), error = SquadronErrorExt.create(err.toString()); - + logger?.e(() => 'Connection to Web Worker failed: $error'); - + fail(error); - + - + UriChecker.exists(entryPoint).then((found) { - + try { - + final msg = (e != null) - + ? '$entryPoint => ${err.runtimeType} $err [${e.filename}(${e.lineno})]' - + : '$entryPoint => ${err.runtimeType} $err'; - + logger?.e(() => 'Unhandled error from Web Worker: $msg.'); - + if (!found) { - + logger?.e(() => 'It seems no Web Worker lives at $entryPoint.'); - + } - + } catch (_) { - + // ignore - + } - + }); - + } - + - + worker.onerror = $errorHandler.toJS; - + worker.onmessageerror = $errorHandler.toJS; - + - + final disconnected = DisconnectedChannel(exceptionManager, logger); - + - + worker.onmessage = (web.MessageEvent? e) { - + try { - + final response = WorkerResponseExt.from(getMessageEventData(e) as List); - + if (!response.unwrapInPlace(disconnected)) { - + return; - + } - + - + final error = response.error; - + if (error != null) { - + logger?.e(() => 'Connection to Web Worker failed: $error'); - + fail(error); - + } else if (!ready.isCompleted) { - + logger?.t('Web Worker is ready'); - + ready.complete(response.result); - + } - + } catch (ex, st) { - + return fail(SquadronException.from(ex, st)); - + } - + }.toJS; - + - + final res = await ready.future; - + if (!res) { - + throw SquadronErrorExt.create('Web Worker is not ready'); - + } - + - + final startRequest = WorkerRequest.start(com.port2, startArguments); - + - + com.port1.onmessage = (web.MessageEvent e) { - + final response = WorkerResponseExt.from(getMessageEventData(e) as List); - + if (!response.unwrapInPlace(disconnected)) { - + return; - + } - + - + final error = response.error; - + if (error != null) { - + logger?.e(() => 'Connection to Web Worker failed: $error'); - + fail(error); - + + } else if (response.endOfStream) { + + + logger?.w('Disconnecting from Isolate'); + + + + channel?.close(); + + + } else if (!completer.isCompleted) { - + logger?.t('Connected to Web Worker'); - - success(_WebChannel._(response.result, logger, exceptionManager)); + + channel = _WebChannel._(response.result, logger, exceptionManager); + + + + success(channel!); - + } else { - + logger?.d(() => 'Unexpected response: $response'); - + } - + }.toJS; - + - + try { - + final data = startRequest.wrapInPlace(); - + final msg = data.jsify(); - + final transfer = Transferables.get(data); - + if (transfer == null || transfer.isEmpty) { - + worker.postMessage(msg); - + } else { - + final jsTransfer = transfer.jsify() as JSArray; - + worker.postMessage(msg, jsTransfer); - + } - + } catch (ex, st) { - + logger?.e(() => 'Failed to post connection request $startRequest: $ex'); - + throw SquadronErrorExt.create( - + 'Failed to post connection request: $ex', st); - + } - + - - final channel = await completer.future; - + + try { + - - await hook?.call(worker); + + final channel = await completer.future; - - + + await hook?.call(worker); + - - logger?.t('Created Web Worker for $entryPoint'); + + logger?.t('Created Web Worker for $entryPoint'); - - return channel; + + return channel; - + + } catch (ex) { + + + logger?.e(() => 'Connection to Isolate failed: $ex'); + + + + rethrow; + + + + } + + } catch (ex, st) { - + ready.future.ignore(); - + completer.future.ignore(); - + logger?.t('Failed to create Web Worker for $entryPoint'); - + com.port1.close(); - + com.port2.close(); - + worker.terminate(); - + throw SquadronException.from(ex, st); - + } finally { - + webEntryPoint.release(); - + } - + } - + - + /// Creates a [_WebChannel] from a [web.MessagePort]. - + Channel? deserialize(PlatformChannel? channelInfo, - + [Logger? logger, ExceptionManager? exceptionManager]) => - + (channelInfo == null) - + ? null - + : _WebChannel._( - + channelInfo, - + logger, - + exceptionManager ?? ExceptionManager(), - + ); diff --git a/doc/coverage/xml/src/_impl/web/_channel_impl.dart.gcov.xml b/doc/coverage/xml/src/_impl/web/_channel_impl.dart.gcov.xml index 272dcb40..555d6387 100644 --- a/doc/coverage/xml/src/_impl/web/_channel_impl.dart.gcov.xml +++ b/doc/coverage/xml/src/_impl/web/_channel_impl.dart.gcov.xml @@ -1,5 +1,5 @@ - + part of '_channel.dart'; @@ -364,9 +364,9 @@ - + void $forwardMessage(WorkerResponse msg) => controller?.add(msg); - + @@ -459,25 +459,25 @@ - + com.port1.onmessage = (web.MessageEvent e) { - + - + final res = WorkerResponseExt.from(getMessageEventData(e)!); - + - + final handler = buffer.isActive ? buffer.add : $forwardMessage; - + - + handler(res); - + - + }.toJS; - + diff --git a/doc/coverage/xml/src/_impl/web/_entry_point_uri.dart.gcov.xml b/doc/coverage/xml/src/_impl/web/_entry_point_uri.dart.gcov.xml index 1b708252..2348442f 100644 --- a/doc/coverage/xml/src/_impl/web/_entry_point_uri.dart.gcov.xml +++ b/doc/coverage/xml/src/_impl/web/_entry_point_uri.dart.gcov.xml @@ -1,5 +1,5 @@ - + import 'dart:js_interop'; diff --git a/doc/coverage/xml/src/_impl/web/_event_buffer.dart.gcov.xml b/doc/coverage/xml/src/_impl/web/_event_buffer.dart.gcov.xml index bce04416..4fc79177 100644 --- a/doc/coverage/xml/src/_impl/web/_event_buffer.dart.gcov.xml +++ b/doc/coverage/xml/src/_impl/web/_event_buffer.dart.gcov.xml @@ -1,5 +1,5 @@ - + import 'dart:async'; @@ -45,9 +45,9 @@ - + bool get isActive => _pauses > 0; - + diff --git a/doc/coverage/xml/src/_impl/web/_local_worker.dart.gcov.xml b/doc/coverage/xml/src/_impl/web/_local_worker.dart.gcov.xml index 2317cae5..0eeb96b9 100644 --- a/doc/coverage/xml/src/_impl/web/_local_worker.dart.gcov.xml +++ b/doc/coverage/xml/src/_impl/web/_local_worker.dart.gcov.xml @@ -1,5 +1,5 @@ - + import 'dart:async'; diff --git a/doc/coverage/xml/src/_impl/web/_patch.dart.gcov.xml b/doc/coverage/xml/src/_impl/web/_patch.dart.gcov.xml index 330e6917..d45461d7 100644 --- a/doc/coverage/xml/src/_impl/web/_patch.dart.gcov.xml +++ b/doc/coverage/xml/src/_impl/web/_patch.dart.gcov.xml @@ -1,5 +1,5 @@ - + import 'dart:js_interop'; @@ -105,17 +105,17 @@ - + List? getMessageEventData(JSObject? obj) { - + - + if (obj != null && obj.has('data')) { - + - + return obj['data'].dartify() as List?; - + } else { @@ -126,9 +126,9 @@ } - + } - + diff --git a/doc/coverage/xml/src/_impl/web/_platform.dart.gcov.xml b/doc/coverage/xml/src/_impl/web/_platform.dart.gcov.xml index 65430900..cd1a861f 100644 --- a/doc/coverage/xml/src/_impl/web/_platform.dart.gcov.xml +++ b/doc/coverage/xml/src/_impl/web/_platform.dart.gcov.xml @@ -1,5 +1,5 @@ - + import '../../converters/cast_converter.dart'; diff --git a/doc/coverage/xml/src/_impl/web/_typedefs.dart.gcov.xml b/doc/coverage/xml/src/_impl/web/_typedefs.dart.gcov.xml index d1f77bd9..4783766b 100644 --- a/doc/coverage/xml/src/_impl/web/_typedefs.dart.gcov.xml +++ b/doc/coverage/xml/src/_impl/web/_typedefs.dart.gcov.xml @@ -1,5 +1,5 @@ - + import 'dart:async'; diff --git a/doc/coverage/xml/src/_impl/web/_uri_checker.dart.gcov.xml b/doc/coverage/xml/src/_impl/web/_uri_checker.dart.gcov.xml index a3f36d42..daa184b9 100644 --- a/doc/coverage/xml/src/_impl/web/_uri_checker.dart.gcov.xml +++ b/doc/coverage/xml/src/_impl/web/_uri_checker.dart.gcov.xml @@ -1,5 +1,5 @@ - + import 'dart:js_interop'; diff --git a/doc/coverage/xml/src/_impl/web/_worker_channel.dart.gcov.xml b/doc/coverage/xml/src/_impl/web/_worker_channel.dart.gcov.xml index d6de4a83..46044733 100644 --- a/doc/coverage/xml/src/_impl/web/_worker_channel.dart.gcov.xml +++ b/doc/coverage/xml/src/_impl/web/_worker_channel.dart.gcov.xml @@ -1,5 +1,5 @@ - + import 'dart:async'; diff --git a/doc/coverage/xml/src/_impl/web/_worker_runner.dart.gcov.xml b/doc/coverage/xml/src/_impl/web/_worker_runner.dart.gcov.xml index e2749321..20135cb3 100644 --- a/doc/coverage/xml/src/_impl/web/_worker_runner.dart.gcov.xml +++ b/doc/coverage/xml/src/_impl/web/_worker_runner.dart.gcov.xml @@ -1,5 +1,5 @@ - + import 'package:web/web.dart' as web; diff --git a/doc/coverage/xml/src/_impl/web/index.xml b/doc/coverage/xml/src/_impl/web/index.xml index 15eae999..40af3cc5 100644 --- a/doc/coverage/xml/src/_impl/web/index.xml +++ b/doc/coverage/xml/src/_impl/web/index.xml @@ -1,8 +1,8 @@ - + - - + + diff --git a/doc/coverage/xml/src/_impl/xplat/_disconnected_channel.dart.gcov.xml b/doc/coverage/xml/src/_impl/xplat/_disconnected_channel.dart.gcov.xml index f87d029a..831f749a 100644 --- a/doc/coverage/xml/src/_impl/xplat/_disconnected_channel.dart.gcov.xml +++ b/doc/coverage/xml/src/_impl/xplat/_disconnected_channel.dart.gcov.xml @@ -1,5 +1,5 @@ - + import 'dart:async'; diff --git a/doc/coverage/xml/src/_impl/xplat/_forward_completer.dart.gcov.xml b/doc/coverage/xml/src/_impl/xplat/_forward_completer.dart.gcov.xml index 21ded758..84ac55b8 100644 --- a/doc/coverage/xml/src/_impl/xplat/_forward_completer.dart.gcov.xml +++ b/doc/coverage/xml/src/_impl/xplat/_forward_completer.dart.gcov.xml @@ -1,5 +1,5 @@ - + import 'dart:async'; diff --git a/doc/coverage/xml/src/_impl/xplat/_forward_stream_controller.dart.gcov.xml b/doc/coverage/xml/src/_impl/xplat/_forward_stream_controller.dart.gcov.xml index 70c6887d..897a0b04 100644 --- a/doc/coverage/xml/src/_impl/xplat/_forward_stream_controller.dart.gcov.xml +++ b/doc/coverage/xml/src/_impl/xplat/_forward_stream_controller.dart.gcov.xml @@ -1,5 +1,5 @@ - + import 'dart:async'; @@ -54,9 +54,9 @@ - + late final StreamController<T> _controller; - + @@ -95,17 +95,17 @@ - + void add(T data) { - + - + if (!_controller.isClosed) _controller.add(data); - + - + } - + @@ -114,9 +114,9 @@ void addError(SquadronException ex) { - + if (!_controller.isClosed) _controller.addError(ex); - + } diff --git a/doc/coverage/xml/src/_impl/xplat/_internal_logger.dart.gcov.xml b/doc/coverage/xml/src/_impl/xplat/_internal_logger.dart.gcov.xml index cba077b5..f9e9675d 100644 --- a/doc/coverage/xml/src/_impl/xplat/_internal_logger.dart.gcov.xml +++ b/doc/coverage/xml/src/_impl/xplat/_internal_logger.dart.gcov.xml @@ -1,5 +1,5 @@ - + import 'package:logger/web.dart'; diff --git a/doc/coverage/xml/src/_impl/xplat/_result_stream.dart.gcov.xml b/doc/coverage/xml/src/_impl/xplat/_result_stream.dart.gcov.xml index 5e7309f7..bef6b10d 100644 --- a/doc/coverage/xml/src/_impl/xplat/_result_stream.dart.gcov.xml +++ b/doc/coverage/xml/src/_impl/xplat/_result_stream.dart.gcov.xml @@ -1,5 +1,5 @@ - + import 'dart:async'; @@ -61,20 +61,20 @@ - + void $decodeStreamOfResponses(WorkerResponse res) { - + - + if (!res.unwrapInPlace(channel)) return; - + - + final hasStreamId = streamIdCompleter!.isCompleted; - + if (res.endOfStream) { @@ -120,9 +120,9 @@ final error = res.error; - + if (error == null && !hasStreamId) { - + // the first result from a streaming operation is the stream ID @@ -131,9 +131,9 @@ streamIdCompleter.complete((res.result as num).toInt()); - + } else if (error != null) { - + _controller.addError(error); @@ -164,9 +164,9 @@ try { - + _controller.add(res.result); - + } catch (ex, st) { @@ -183,13 +183,13 @@ - + final canceled = token?.exception; - + - + if (canceled != null) { - + _controller.addError(canceled); @@ -200,9 +200,9 @@ } - + } - + @@ -478,9 +478,9 @@ - + late final ForwardStreamController<dynamic> _controller; - + diff --git a/doc/coverage/xml/src/_impl/xplat/_time_stamp.dart.gcov.xml b/doc/coverage/xml/src/_impl/xplat/_time_stamp.dart.gcov.xml index 7efb515f..cf5a6dd0 100644 --- a/doc/coverage/xml/src/_impl/xplat/_time_stamp.dart.gcov.xml +++ b/doc/coverage/xml/src/_impl/xplat/_time_stamp.dart.gcov.xml @@ -1,5 +1,5 @@ - + final _latestUPDEpoch = DateTime.utc(2020, 02, 02); // universal palindrome date diff --git a/doc/coverage/xml/src/_impl/xplat/_token_id.dart.gcov.xml b/doc/coverage/xml/src/_impl/xplat/_token_id.dart.gcov.xml index d15eed8f..a0c7f1db 100644 --- a/doc/coverage/xml/src/_impl/xplat/_token_id.dart.gcov.xml +++ b/doc/coverage/xml/src/_impl/xplat/_token_id.dart.gcov.xml @@ -1,5 +1,5 @@ - + import '../../typedefs.dart'; diff --git a/doc/coverage/xml/src/_impl/xplat/_transferables.dart.gcov.xml b/doc/coverage/xml/src/_impl/xplat/_transferables.dart.gcov.xml index b6dc926c..f3dfb969 100644 --- a/doc/coverage/xml/src/_impl/xplat/_transferables.dart.gcov.xml +++ b/doc/coverage/xml/src/_impl/xplat/_transferables.dart.gcov.xml @@ -1,5 +1,5 @@ - + import '../../exceptions/squadron_error.dart'; diff --git a/doc/coverage/xml/src/_impl/xplat/_worker_runner.dart.gcov.xml b/doc/coverage/xml/src/_impl/xplat/_worker_runner.dart.gcov.xml index 99bde47e..a6b8296a 100644 --- a/doc/coverage/xml/src/_impl/xplat/_worker_runner.dart.gcov.xml +++ b/doc/coverage/xml/src/_impl/xplat/_worker_runner.dart.gcov.xml @@ -1,5 +1,5 @@ - + import 'dart:async'; @@ -14,10 +14,10 @@ - import '../../exceptions/squadron_error.dart'; + import '../../../squadron.dart'; - import '../../local_worker/local_worker.dart'; + import '../../exceptions/squadron_error.dart'; import '../../tokens/_cancelation_token_ref.dart'; @@ -26,229 +26,228 @@ import '../../tokens/_squadron_cancelation_token.dart'; - import '../../typedefs.dart'; - - - import '../../worker/worker_channel.dart'; - - import '../../worker/worker_request.dart'; - - import '../../worker_service.dart'; - - + import '_internal_logger.dart'; - + - + class WorkerRunner { - + /// Constructs a new worker runner. - + WorkerRunner(this._terminate); - + - + void Function(WorkerRunner) _terminate; - + - + final internalLogger = InternalLogger(); - + - - Map<int, CommandHandler>? _operations; - - - - ServiceInstaller? _installer; + + WorkerService? _service; - + - + final _cancelTokens = <String, CancelationTokenReference>{}; - + - + bool _terminationRequested = false; - + int _executing = 0; - + - + final _streamCancelers = <int, SquadronCallback>{}; - + int _streamId = 0; - + - + void Function(OutputEvent)? _logForwarder; - + - + /// Constructs a new worker runner for a [localWorker]. - + factory WorkerRunner.use(LocalWorker localWorker) { - - final runner = WorkerRunner((r) => r._operations?.clear()); + + final runner = WorkerRunner((r) { - - runner._operations = {...localWorker.service.operations}; - + + r.internalLogger.t('Terminating local Worker'); - + + r._service = null; + + + }); + + + runner._service = localWorker; + + + return runner; - + } - + - + /// Called by the platform worker upon startup, in response to a start - + /// [WorkerRequest]. [channelInfo] is an opaque object sent back from the - + /// platform worker to the Squadron [Worker] and used to communicate with the - + /// platform worker. Typically, [channelInfo] would be a [SendPort] (native) - + /// or a [MessagePort] (browser). [initializer] is called to build the - - /// [WorkerService] associated to the worker. The runner's [_operations] map + + /// [WorkerService] associated to the worker. The runner's [_service] map - + /// will be set with operations from the service. - + Future<void> connect(WorkerRequest? startRequest, PlatformChannel channelInfo, - + WorkerInitializer initializer) async { - + WorkerChannel? channel; - + try { - + startRequest?.unwrapInPlace(internalLogger); - + channel = startRequest?.channel; - + - + if (startRequest == null) { - + throw SquadronErrorExt.create('Missing connection request'); - + } else if (channel == null) { - + throw SquadronErrorExt.create('Missing client for connection request'); - + } - + - + if (_logForwarder == null) { - + final logger = channel.log; - + _logForwarder = (event) => logger(event.origin); - + Logger.addOutputListener(_logForwarder!); - + } - + - + if (!startRequest.isConnection) { - + throw SquadronErrorExt.create('Connection request expected'); - - } else if (_operations != null) { + + } else if (_service != null) { - + throw SquadronErrorExt.create('Already connected'); - + } - + - - final service = await initializer(startRequest); - + + _service = await initializer(startRequest); + + + + - - if (service.operations.keys.where((k) => k <= 0).isNotEmpty) { - + + if (_service!.operations.keys.where((k) => k <= 0).isNotEmpty) { + throw SquadronErrorExt.create( @@ -266,821 +265,939 @@ - - _operations = {...service.operations}; - + + channel.connect(channelInfo); + - - if (service is ServiceInstaller) { - + + if (_service is ServiceInstaller) { + - - _installer = service as ServiceInstaller; - + + _installCompleter = Completer() + - await _installer!.install(); + ..complete((() async { - } + try { - - + + await (_service as ServiceInstaller).install(); + - - channel.connect(channelInfo); - + + } catch (ex, st) { - + + internalLogger.e(() => 'Service installation failed: $ex'); + + + + channel?.error(ex, st); + + + + channel?.closeStream(); + + + + _installResult = SquadronException.from(ex, st); + + + + } + + + })()); + + + + } + + } catch (ex, st) { - + internalLogger.e(() => 'Connection failed: $ex'); - + channel?.error(ex, st); - + _exit(); - + } - + } - + - + + Completer<void>? _installCompleter; + + + SquadronException? _installResult; + + + + + /// [WorkerRequest] handler dispatching commands according to the - - /// [_operations] map. Make sure this method doesn't throw. + + /// [_service] map. Make sure this method doesn't throw. - + void processRequest(WorkerRequest request) async { - + WorkerChannel? channel; - + try { - + request.unwrapInPlace(internalLogger); - + channel = request.channel; - + - - // ==== these requests do not send a response ==== - - - - - + if (request.isTermination) { - + // terminate the worker - + return _shutdown(); - - } else if (request.isTokenCancelation) { + + } + + + + + + // check installation result if necessary + + + final pendingInstallation = _installCompleter?.future; + + + + if (pendingInstallation != null) { + + + + await pendingInstallation; + + + _installCompleter = null; + + + + } + + + + + + if (_installResult != null) { + + + + // service installation failed + + + throw _installResult!; + + + + } + + + + + + // ==== these requests do not send a response ==== + + + + + + if (request.isTokenCancelation) { - + // cancel a token - + final token = request.cancelToken!; - + return _getTokenRef(token).update(token); - + } else if (request.isStreamCancelation) { - + // cancel a stream - + final canceler = _streamCancelers[request.streamId]; - + return canceler?.call(); - + } - + - + // make sure the worker is connected - + - + if (request.isConnection) { - + // connection requests are handled by connect(). - + throw SquadronErrorExt.create( - + 'Unexpected connection request: $request'); - - } else if (_operations == null) { + + } else if (_service == null) { - + // commands are not available yet (maybe connect() wasn't called or awaited) - + throw SquadronErrorExt.create('Worker service is not ready'); - + } - + - + // ==== other requests require a client to send the response ==== - + - + if (channel == null) { - + throw SquadronErrorExt.create('Missing client for request: $request'); - + } - + - + final token = request.cancelToken; - + token?.throwIfCanceled(); - + - + // start monitoring execution - + final tokenRef = _begin(request); - + try { - + // find the operation matching the request command - - final cmd = request.command, op = _operations![cmd]; - + + final cmd = request.command, op = _service?.operations[cmd]; + - + if (op == null) { - + throw SquadronErrorExt.create('Unknown command: $cmd'); - + } - + - + // process - + var result = op(request); - + if (result is Future) { - + result = await result; - + } - + - + final reply = request.reply!; - + if (result is Stream && channel.canStream(result)) { - + // result is a stream: forward data to the client - + final replyWithError = channel.error; - + void postError(Object exception, [StackTrace? stackTrace]) { - + replyWithError(exception, stackTrace, cmd); - + } - + - + void post(data) { - + try { - + reply(data); - + } catch (ex, st) { - + postError(ex, st); - + } - + } - + - + await _pipe(result, channel, post, postError, token); - + } else { - + // result is a value: send to the client - + reply(result); - + } - + } finally { - + // stop monitoring execution - + _done(tokenRef); - + } - + } catch (ex, st) { - + if (channel != null) { - + channel.error(ex, st, request.command); - + } else { - + internalLogger.e('Unhandled error: $ex'); - + } - + } - + } - + - + CancelationTokenReference _getTokenRef(SquadronCancelationToken? token) => - + (token == null) - + ? CancelationTokenReference.noToken - + : _cancelTokens.putIfAbsent( - + token.id, () => CancelationTokenReference(token.id)); - + - + /// Starts monitoring execution of this [request]. If the request contains a - + /// cancelation token, it is overridden with a [CancelationTokenReference] - + /// and this reference is returned to the sender. Otherwise, returns - + /// [CancelationTokenReference.noToken]. - + CancelationTokenReference _begin(WorkerRequest request) { - + _executing++; - + final token = _getTokenRef(request.cancelToken); - + token.usedBy(request); - + return token; - + } - + - + /// Stops monitoring execution and releases the [tokenRef]. - + void _done(CancelationTokenReference tokenRef) { - + tokenRef.release(); - + if (tokenRef.refCount == 0) { - + _cancelTokens.remove(tokenRef.id); - + } - + _executing--; - + if (_terminationRequested && _executing == 0) { - + _unmount(); - + } - + } - + - + /// Forwards stream events to client. - + Future<void> _pipe( - + Stream<dynamic> stream, - + WorkerChannel channel, - + void Function(dynamic) post, - + void Function(Object exception, [StackTrace? stackTrace]) postError, - + SquadronCancelationToken? token, - + ) { - + late final StreamSubscription subscription; - + final done = Completer(); - + - + late final int streamId; - + - + // send endOfStream to client - + Future<void> onDone() async { - + _unregisterStreamCanceler(streamId); - + channel.closeStream(); - + await subscription.cancel(); - + done.complete(); - + } - + - + final bool Function() checkToken; - + if (token == null) { - + checkToken = () => true; - + } else { - + checkToken = () { - + final ex = token.exception; - + if (ex != null) { - + postError(ex); - + onDone(); - + } - + return (ex == null); - + }; - + } - + - + // register stream canceler callback and connect stream with client - + streamId = _registerStreamCanceler(onDone); - + post(streamId); - + if (checkToken()) { - + // start forwarding messages to the client - + subscription = stream.listen( - + (data) { - + if (checkToken()) post(data); - + }, - + onError: (ex, st) { - + if (checkToken()) postError(ex, st); - + }, - + onDone: onDone, - + cancelOnError: false, - + ); - + } - + - + return done.future; - + } - + - + /// Assigns a stream ID to the stream canceler callback and registers the - + /// callback. - + int _registerStreamCanceler(SquadronCallback canceler) { - + final streamId = ++_streamId; - + _streamCancelers[streamId] = canceler; - + return streamId; - + } - + - + /// Unregisters the stream canceled callback associated to the [streamId]. - + void _unregisterStreamCanceler(int streamId) { - + _streamCancelers.remove(streamId); - + } - + - + /// Terminates the worker if there is no pending execution. Otherwise, marks - + /// the worker as terminating and termination will be effective when all - + /// pending executions have completed. - + void _shutdown() { - + _terminationRequested = true; - + if (_executing == 0) { - + _unmount(); - + } - + } - + - + // should not throw - + void _unmount() async { - + try { - + // uninstall the service if necessary - - await _installer?.uninstall(); - + + if (_service is ServiceInstaller) { + + + + // check installation result + + + final pendingInstallation = _installCompleter?.future; + + + + if (pendingInstallation != null) { + + + await pendingInstallation; - + + _installCompleter = null; + + + } + + + if (_installResult == null) { + + + + // uninstall iif the service installed succesfuly + + + await (_service as ServiceInstaller).uninstall(); + + + + } + + + } + + } catch (ex) { - + internalLogger.e('Service uninstallation failed with error: $ex'); - + } finally { - + _exit(); - + } - + } - + - + // should not throw - + void _exit() { - + try { - + _terminate(this); - + } catch (ex) { - + internalLogger.e('Worker termination failed with error: $ex'); - + } - + if (_logForwarder != null) { - + Logger.removeOutputListener(_logForwarder!); - + } - + } - + } diff --git a/doc/coverage/xml/src/_impl/xplat/index.xml b/doc/coverage/xml/src/_impl/xplat/index.xml index fb4eed1d..38bb89cf 100644 --- a/doc/coverage/xml/src/_impl/xplat/index.xml +++ b/doc/coverage/xml/src/_impl/xplat/index.xml @@ -1,8 +1,8 @@ - + - - + + diff --git a/doc/coverage/xml/src/annotations/index.xml b/doc/coverage/xml/src/annotations/index.xml index e5d3c867..7c240349 100644 --- a/doc/coverage/xml/src/annotations/index.xml +++ b/doc/coverage/xml/src/annotations/index.xml @@ -1,10 +1,13 @@ - + + - + + + diff --git a/doc/coverage/xml/src/annotations/squadron_method.dart.gcov.xml b/doc/coverage/xml/src/annotations/squadron_method.dart.gcov.xml index 9927dec7..8a21c25f 100644 --- a/doc/coverage/xml/src/annotations/squadron_method.dart.gcov.xml +++ b/doc/coverage/xml/src/annotations/squadron_method.dart.gcov.xml @@ -1,5 +1,5 @@ - + import '../channel.dart'; diff --git a/doc/coverage/xml/src/annotations/squadron_service.dart.gcov.xml b/doc/coverage/xml/src/annotations/squadron_service.dart.gcov.xml index 15b23e9f..5fbf860b 100644 --- a/doc/coverage/xml/src/annotations/squadron_service.dart.gcov.xml +++ b/doc/coverage/xml/src/annotations/squadron_service.dart.gcov.xml @@ -1,130 +1,128 @@ - + import '../pool/worker_pool.dart'; - + import 'target_platform.dart'; - /// Annotation for service classes to be wrapped as workers. + - class SquadronService { + const localService = SquadronService.local(); - - const SquadronService({ + + - this.pool = true, + /// Annotation for service classes to be wrapped as workers. - this.targetPlatform = TargetPlatform.all, + class SquadronService { - - String? baseUrl, + + const SquadronService({ - }) : baseUrl = baseUrl ?? ''; + this.pool = true, - + this.targetPlatform = TargetPlatform.all, - - const SquadronService.web({bool pool = true, String? baseUrl}) + + String? baseUrl, - - : this(pool: pool, targetPlatform: TargetPlatform.web, baseUrl: baseUrl); + + }) : baseUrl = baseUrl ?? '', - + local = false; - - const SquadronService.vm({bool pool = true}) + + - : this(pool: pool, targetPlatform: TargetPlatform.vm); + const SquadronService.web({bool pool = true, String? baseUrl}) - - + + : this(pool: pool, targetPlatform: TargetPlatform.web, baseUrl: baseUrl); - /// Controls code generation of a [WorkerPool] exposing the target service class. + - - /// `true` by default. + + const SquadronService.vm({bool pool = true}) - - final bool pool; + + : this(pool: pool, targetPlatform: TargetPlatform.vm); - - /// Controls code generation of a entry points for various platforms. + + const SquadronService.local() + - final int targetPlatform; + : pool = false, - + local = true, - /// For Web-based workers, indicates the [baseUrl] where the Web Worker will + targetPlatform = TargetPlatform.all, - /// be exposed in production. + baseUrl = ''; - final String baseUrl; + - } + /// Controls code generation of a [WorkerPool] exposing the target service class. - + /// `true` by default. - final class TargetPlatform { + final bool pool; - static const vm = 1; + - static const js = 2; + /// Controls code generation of a [LocalWorkerClient] exposing the target service class. - static const wasm = 4; + /// `false` by default. - + final bool local; - static const web = js | wasm; + - static const all = vm | js | wasm; + /// Controls code generation of a entry points for various platforms. - } + final int targetPlatform; - extension TargetPlatformExt on int { - - - bool get hasVm => (this & TargetPlatform.vm) != 0; + /// For Web-based workers, indicates the [baseUrl] where the Web Worker will - - bool get hasJs => (this & TargetPlatform.js) != 0; + + /// be exposed in production. - - bool get hasWasm => (this & TargetPlatform.wasm) != 0; + + final String baseUrl; - + } diff --git a/doc/coverage/xml/src/annotations/target_platform.dart.gcov.xml b/doc/coverage/xml/src/annotations/target_platform.dart.gcov.xml new file mode 100644 index 00000000..8747ec4f --- /dev/null +++ b/doc/coverage/xml/src/annotations/target_platform.dart.gcov.xml @@ -0,0 +1,50 @@ + + + + + final class TargetPlatform { + + + static const vm = 1; + + + static const js = 2; + + + static const wasm = 4; + + + + + + static const web = js | wasm; + + + static const all = vm | js | wasm; + + + } + + + + + + extension TargetPlatformExt on int { + + + bool get hasVm => (this & TargetPlatform.vm) != 0; + + + bool get hasJs => (this & TargetPlatform.js) != 0; + + + bool get hasWasm => (this & TargetPlatform.wasm) != 0; + + + } + + + + + + diff --git a/doc/coverage/xml/src/bootstrapper.dart.gcov.xml b/doc/coverage/xml/src/bootstrapper.dart.gcov.xml index 698f7f1b..20a54c0f 100644 --- a/doc/coverage/xml/src/bootstrapper.dart.gcov.xml +++ b/doc/coverage/xml/src/bootstrapper.dart.gcov.xml @@ -1,5 +1,5 @@ - + import '_impl/xplat/_bootstrapper.dart' diff --git a/doc/coverage/xml/src/channel.dart.gcov.xml b/doc/coverage/xml/src/channel.dart.gcov.xml index e32b3779..6d11ad72 100644 --- a/doc/coverage/xml/src/channel.dart.gcov.xml +++ b/doc/coverage/xml/src/channel.dart.gcov.xml @@ -1,5 +1,5 @@ - + import 'dart:async'; diff --git a/doc/coverage/xml/src/concurrency_settings.dart.gcov.xml b/doc/coverage/xml/src/concurrency_settings.dart.gcov.xml index 60f20483..3b36a3ac 100644 --- a/doc/coverage/xml/src/concurrency_settings.dart.gcov.xml +++ b/doc/coverage/xml/src/concurrency_settings.dart.gcov.xml @@ -1,5 +1,5 @@ - + /// Concurrency settings governing parallelization of workers in a [WorkerPool]. diff --git a/doc/coverage/xml/src/converters/cast_converter.dart.gcov.xml b/doc/coverage/xml/src/converters/cast_converter.dart.gcov.xml index 062ffd96..f6edc2b6 100644 --- a/doc/coverage/xml/src/converters/cast_converter.dart.gcov.xml +++ b/doc/coverage/xml/src/converters/cast_converter.dart.gcov.xml @@ -1,5 +1,5 @@ - + import '../../squadron.dart'; diff --git a/doc/coverage/xml/src/converters/converter.dart.gcov.xml b/doc/coverage/xml/src/converters/converter.dart.gcov.xml index 6643fea3..0ac5a8d9 100644 --- a/doc/coverage/xml/src/converters/converter.dart.gcov.xml +++ b/doc/coverage/xml/src/converters/converter.dart.gcov.xml @@ -1,5 +1,5 @@ - + import 'dart:typed_data'; diff --git a/doc/coverage/xml/src/converters/direct_cast_converter.dart.gcov.xml b/doc/coverage/xml/src/converters/direct_cast_converter.dart.gcov.xml index 4b669d80..e6a13ed9 100644 --- a/doc/coverage/xml/src/converters/direct_cast_converter.dart.gcov.xml +++ b/doc/coverage/xml/src/converters/direct_cast_converter.dart.gcov.xml @@ -1,5 +1,5 @@ - + import '../../squadron.dart'; diff --git a/doc/coverage/xml/src/converters/in_place_converter.dart.gcov.xml b/doc/coverage/xml/src/converters/in_place_converter.dart.gcov.xml index aab3455f..082e69cd 100644 --- a/doc/coverage/xml/src/converters/in_place_converter.dart.gcov.xml +++ b/doc/coverage/xml/src/converters/in_place_converter.dart.gcov.xml @@ -1,5 +1,5 @@ - + import 'converter.dart'; diff --git a/doc/coverage/xml/src/converters/index.xml b/doc/coverage/xml/src/converters/index.xml index fb80d2ed..eecd4e09 100644 --- a/doc/coverage/xml/src/converters/index.xml +++ b/doc/coverage/xml/src/converters/index.xml @@ -1,5 +1,5 @@ - + @@ -13,12 +13,12 @@ - - - + + + diff --git a/doc/coverage/xml/src/converters/lazy_in_place_converter.dart.gcov.xml b/doc/coverage/xml/src/converters/lazy_in_place_converter.dart.gcov.xml index 2d84b0c8..472f6b16 100644 --- a/doc/coverage/xml/src/converters/lazy_in_place_converter.dart.gcov.xml +++ b/doc/coverage/xml/src/converters/lazy_in_place_converter.dart.gcov.xml @@ -1,5 +1,5 @@ - + import 'converter.dart'; diff --git a/doc/coverage/xml/src/converters/lazy_in_place_list.dart.gcov.xml b/doc/coverage/xml/src/converters/lazy_in_place_list.dart.gcov.xml index 65a848bf..59582c03 100644 --- a/doc/coverage/xml/src/converters/lazy_in_place_list.dart.gcov.xml +++ b/doc/coverage/xml/src/converters/lazy_in_place_list.dart.gcov.xml @@ -1,5 +1,5 @@ - + import 'dart:math' as math; diff --git a/doc/coverage/xml/src/converters/lazy_in_place_map.dart.gcov.xml b/doc/coverage/xml/src/converters/lazy_in_place_map.dart.gcov.xml index 1ec87d63..c0c1a98c 100644 --- a/doc/coverage/xml/src/converters/lazy_in_place_map.dart.gcov.xml +++ b/doc/coverage/xml/src/converters/lazy_in_place_map.dart.gcov.xml @@ -1,5 +1,5 @@ - + import 'package:meta/meta.dart'; diff --git a/doc/coverage/xml/src/converters/num_converter.dart.gcov.xml b/doc/coverage/xml/src/converters/num_converter.dart.gcov.xml index cf194065..c5771884 100644 --- a/doc/coverage/xml/src/converters/num_converter.dart.gcov.xml +++ b/doc/coverage/xml/src/converters/num_converter.dart.gcov.xml @@ -1,5 +1,5 @@ - + import 'converter.dart'; diff --git a/doc/coverage/xml/src/exceptions/_well_known_exceptions.dart.gcov.xml b/doc/coverage/xml/src/exceptions/_well_known_exceptions.dart.gcov.xml index ef5f794b..9d03b50e 100644 --- a/doc/coverage/xml/src/exceptions/_well_known_exceptions.dart.gcov.xml +++ b/doc/coverage/xml/src/exceptions/_well_known_exceptions.dart.gcov.xml @@ -1,5 +1,5 @@ - + import 'dart:async'; diff --git a/doc/coverage/xml/src/exceptions/exception_manager.dart.gcov.xml b/doc/coverage/xml/src/exceptions/exception_manager.dart.gcov.xml index e99d6468..7fe836be 100644 --- a/doc/coverage/xml/src/exceptions/exception_manager.dart.gcov.xml +++ b/doc/coverage/xml/src/exceptions/exception_manager.dart.gcov.xml @@ -1,5 +1,5 @@ - + import 'package:meta/meta.dart'; @@ -171,17 +171,17 @@ /// Deserializes a [List] that was produced by [serialize]. - + SquadronException? deserialize(List? data) { - + - + if (data == null || data.isEmpty) { - + - + return null; - + } @@ -221,9 +221,9 @@ } - + } - + } diff --git a/doc/coverage/xml/src/exceptions/index.xml b/doc/coverage/xml/src/exceptions/index.xml index 8597030a..13a217b0 100644 --- a/doc/coverage/xml/src/exceptions/index.xml +++ b/doc/coverage/xml/src/exceptions/index.xml @@ -1,5 +1,5 @@ - + diff --git a/doc/coverage/xml/src/exceptions/squadron_canceled_exception.dart.gcov.xml b/doc/coverage/xml/src/exceptions/squadron_canceled_exception.dart.gcov.xml index 0db408a7..e18057fd 100644 --- a/doc/coverage/xml/src/exceptions/squadron_canceled_exception.dart.gcov.xml +++ b/doc/coverage/xml/src/exceptions/squadron_canceled_exception.dart.gcov.xml @@ -1,5 +1,5 @@ - + import 'package:cancelation_token/cancelation_token.dart'; diff --git a/doc/coverage/xml/src/exceptions/squadron_canceled_exceptions.dart.gcov.xml b/doc/coverage/xml/src/exceptions/squadron_canceled_exceptions.dart.gcov.xml index 462cd526..38b7a6fa 100644 --- a/doc/coverage/xml/src/exceptions/squadron_canceled_exceptions.dart.gcov.xml +++ b/doc/coverage/xml/src/exceptions/squadron_canceled_exceptions.dart.gcov.xml @@ -1,5 +1,5 @@ - + import 'dart:convert'; diff --git a/doc/coverage/xml/src/exceptions/squadron_error.dart.gcov.xml b/doc/coverage/xml/src/exceptions/squadron_error.dart.gcov.xml index e548652a..89f225dd 100644 --- a/doc/coverage/xml/src/exceptions/squadron_error.dart.gcov.xml +++ b/doc/coverage/xml/src/exceptions/squadron_error.dart.gcov.xml @@ -1,5 +1,5 @@ - + import 'package:meta/meta.dart'; @@ -79,9 +79,9 @@ static SquadronError create(String message, [StackTrace? stackTrace]) => - + SquadronError._(message, stackTrace); - + diff --git a/doc/coverage/xml/src/exceptions/squadron_exception.dart.gcov.xml b/doc/coverage/xml/src/exceptions/squadron_exception.dart.gcov.xml index a8ee5bb6..56c531a4 100644 --- a/doc/coverage/xml/src/exceptions/squadron_exception.dart.gcov.xml +++ b/doc/coverage/xml/src/exceptions/squadron_exception.dart.gcov.xml @@ -1,5 +1,5 @@ - + import 'dart:async'; @@ -31,13 +31,13 @@ abstract class SquadronException implements Exception { - + SquadronException.init(this.message, [this._stackTrace]) { - + - + if (_stackTrace == null) { - + try { @@ -61,9 +61,9 @@ } - + } - + @@ -77,16 +77,16 @@ /// [WorkerException] wrapping [error] and [stackTrace]. - + static SquadronException from(Object error, - + [StackTrace? stackTrace, int? command]) { - + if (error is WorkerException) { - + if (command != null) error.setCommand(command); @@ -130,9 +130,9 @@ } - + } - + diff --git a/doc/coverage/xml/src/exceptions/squadron_timeout_exception.dart.gcov.xml b/doc/coverage/xml/src/exceptions/squadron_timeout_exception.dart.gcov.xml index 8816ac98..bfe9691b 100644 --- a/doc/coverage/xml/src/exceptions/squadron_timeout_exception.dart.gcov.xml +++ b/doc/coverage/xml/src/exceptions/squadron_timeout_exception.dart.gcov.xml @@ -1,5 +1,5 @@ - + import 'package:cancelation_token/cancelation_token.dart'; diff --git a/doc/coverage/xml/src/exceptions/task_canceled_exception.dart.gcov.xml b/doc/coverage/xml/src/exceptions/task_canceled_exception.dart.gcov.xml index 9e4b0d61..0cfc87f6 100644 --- a/doc/coverage/xml/src/exceptions/task_canceled_exception.dart.gcov.xml +++ b/doc/coverage/xml/src/exceptions/task_canceled_exception.dart.gcov.xml @@ -1,5 +1,5 @@ - + import 'dart:convert'; diff --git a/doc/coverage/xml/src/exceptions/worker_exception.dart.gcov.xml b/doc/coverage/xml/src/exceptions/worker_exception.dart.gcov.xml index 81655132..57563063 100644 --- a/doc/coverage/xml/src/exceptions/worker_exception.dart.gcov.xml +++ b/doc/coverage/xml/src/exceptions/worker_exception.dart.gcov.xml @@ -1,5 +1,5 @@ - + import 'package:meta/meta.dart'; diff --git a/doc/coverage/xml/src/index.xml b/doc/coverage/xml/src/index.xml index 6d298e25..bfa63f15 100644 --- a/doc/coverage/xml/src/index.xml +++ b/doc/coverage/xml/src/index.xml @@ -1,5 +1,5 @@ - + diff --git a/doc/coverage/xml/src/local_worker/index.xml b/doc/coverage/xml/src/local_worker/index.xml index 30cfa770..bfa63a0b 100644 --- a/doc/coverage/xml/src/local_worker/index.xml +++ b/doc/coverage/xml/src/local_worker/index.xml @@ -1,11 +1,11 @@ - + - - + + diff --git a/doc/coverage/xml/src/local_worker/local_worker.dart.gcov.xml b/doc/coverage/xml/src/local_worker/local_worker.dart.gcov.xml index 2570b3f5..90fd9c4f 100644 --- a/doc/coverage/xml/src/local_worker/local_worker.dart.gcov.xml +++ b/doc/coverage/xml/src/local_worker/local_worker.dart.gcov.xml @@ -1,5 +1,5 @@ - + import 'dart:async'; @@ -89,7 +89,7 @@ /// worker are deserialized as [WorkerRequest]s and dispatched to a handler - /// defined in the [service]'s [WorkerService.operations] map according to the + /// defined in the [_service]'s [WorkerService.operations] map according to the /// [WorkerRequest.command]. @@ -104,7 +104,7 @@ implements WorkerService, IWorker { - LocalWorker(this.service); + LocalWorker(this._service); @@ -126,7 +126,7 @@ - final W service; + final W _service; @@ -224,15 +224,16 @@ - /// Local Workers do not need an [operations] map. + /// Forward to underlying service. - + @override - - - final Map<int, CommandHandler> operations = WorkerService.noOperations; + + Map<int, CommandHandler> get operations => _service.operations; + + } diff --git a/doc/coverage/xml/src/local_worker/local_worker_client.dart.gcov.xml b/doc/coverage/xml/src/local_worker/local_worker_client.dart.gcov.xml index 3b2b64bc..e3fe4801 100644 --- a/doc/coverage/xml/src/local_worker/local_worker_client.dart.gcov.xml +++ b/doc/coverage/xml/src/local_worker/local_worker_client.dart.gcov.xml @@ -1,5 +1,5 @@ - + import 'dart:async'; @@ -97,7 +97,7 @@ {List args = const [], - SquadronCancelationToken? token, + CancelationToken? token, bool inspectRequest = false, diff --git a/doc/coverage/xml/src/marshalers/generic_marshaler.dart.gcov.xml b/doc/coverage/xml/src/marshalers/generic_marshaler.dart.gcov.xml index 82862c7d..d4a10021 100644 --- a/doc/coverage/xml/src/marshalers/generic_marshaler.dart.gcov.xml +++ b/doc/coverage/xml/src/marshalers/generic_marshaler.dart.gcov.xml @@ -1,5 +1,5 @@ - + import 'squadron_marshaler.dart'; diff --git a/doc/coverage/xml/src/marshalers/identity_marshaler.dart.gcov.xml b/doc/coverage/xml/src/marshalers/identity_marshaler.dart.gcov.xml index eb1f8164..3bc440cc 100644 --- a/doc/coverage/xml/src/marshalers/identity_marshaler.dart.gcov.xml +++ b/doc/coverage/xml/src/marshalers/identity_marshaler.dart.gcov.xml @@ -1,5 +1,5 @@ - + import 'squadron_marshaler.dart'; diff --git a/doc/coverage/xml/src/marshalers/index.xml b/doc/coverage/xml/src/marshalers/index.xml index b4d42302..8a56e4f5 100644 --- a/doc/coverage/xml/src/marshalers/index.xml +++ b/doc/coverage/xml/src/marshalers/index.xml @@ -1,5 +1,5 @@ - + diff --git a/doc/coverage/xml/src/marshalers/squadron_marshaler.dart.gcov.xml b/doc/coverage/xml/src/marshalers/squadron_marshaler.dart.gcov.xml index 6ff5863d..13e7ceba 100644 --- a/doc/coverage/xml/src/marshalers/squadron_marshaler.dart.gcov.xml +++ b/doc/coverage/xml/src/marshalers/squadron_marshaler.dart.gcov.xml @@ -1,5 +1,5 @@ - + /// Base class to serialize/deserialize data of type [T] to a transferable type [S]. diff --git a/doc/coverage/xml/src/pool/_pool_worker.dart.gcov.xml b/doc/coverage/xml/src/pool/_pool_worker.dart.gcov.xml index 713f1839..c04ca86a 100644 --- a/doc/coverage/xml/src/pool/_pool_worker.dart.gcov.xml +++ b/doc/coverage/xml/src/pool/_pool_worker.dart.gcov.xml @@ -1,5 +1,5 @@ - + import '../stats/worker_stat.dart'; diff --git a/doc/coverage/xml/src/pool/_worker_stream_task.dart.gcov.xml b/doc/coverage/xml/src/pool/_worker_stream_task.dart.gcov.xml index 3f7f1254..ede49e02 100644 --- a/doc/coverage/xml/src/pool/_worker_stream_task.dart.gcov.xml +++ b/doc/coverage/xml/src/pool/_worker_stream_task.dart.gcov.xml @@ -1,5 +1,5 @@ - + import 'dart:async'; @@ -131,9 +131,9 @@ - + late final ForwardStreamController<T> _controller; - + @@ -167,16 +167,16 @@ - + void _onData(T data) => _controller.add(data); - + - + void _onError(ex, st) => _controller.addError(SquadronException.from(ex, st)); - + diff --git a/doc/coverage/xml/src/pool/_worker_task.dart.gcov.xml b/doc/coverage/xml/src/pool/_worker_task.dart.gcov.xml index 6f2eb091..89a7abd1 100644 --- a/doc/coverage/xml/src/pool/_worker_task.dart.gcov.xml +++ b/doc/coverage/xml/src/pool/_worker_task.dart.gcov.xml @@ -1,5 +1,5 @@ - + import 'dart:async'; diff --git a/doc/coverage/xml/src/pool/_worker_value_task.dart.gcov.xml b/doc/coverage/xml/src/pool/_worker_value_task.dart.gcov.xml index 1f2b549c..6a8ba482 100644 --- a/doc/coverage/xml/src/pool/_worker_value_task.dart.gcov.xml +++ b/doc/coverage/xml/src/pool/_worker_value_task.dart.gcov.xml @@ -1,5 +1,5 @@ - + import 'dart:async'; diff --git a/doc/coverage/xml/src/pool/index.xml b/doc/coverage/xml/src/pool/index.xml index 6d473f5d..4d821993 100644 --- a/doc/coverage/xml/src/pool/index.xml +++ b/doc/coverage/xml/src/pool/index.xml @@ -1,5 +1,5 @@ - + diff --git a/doc/coverage/xml/src/pool/worker_pool.dart.gcov.xml b/doc/coverage/xml/src/pool/worker_pool.dart.gcov.xml index f4b14d3a..826a3a3f 100644 --- a/doc/coverage/xml/src/pool/worker_pool.dart.gcov.xml +++ b/doc/coverage/xml/src/pool/worker_pool.dart.gcov.xml @@ -1,5 +1,5 @@ - + import 'dart:async'; diff --git a/doc/coverage/xml/src/squadron_platform_type.dart.gcov.xml b/doc/coverage/xml/src/squadron_platform_type.dart.gcov.xml index 942a8907..f0951c1a 100644 --- a/doc/coverage/xml/src/squadron_platform_type.dart.gcov.xml +++ b/doc/coverage/xml/src/squadron_platform_type.dart.gcov.xml @@ -1,5 +1,5 @@ - + enum SquadronPlatformType { diff --git a/doc/coverage/xml/src/squadron_singleton.dart.gcov.xml b/doc/coverage/xml/src/squadron_singleton.dart.gcov.xml index 137c4062..d8ce5608 100644 --- a/doc/coverage/xml/src/squadron_singleton.dart.gcov.xml +++ b/doc/coverage/xml/src/squadron_singleton.dart.gcov.xml @@ -1,5 +1,5 @@ - + import '_impl/xplat/_platform.dart' diff --git a/doc/coverage/xml/src/stats/index.xml b/doc/coverage/xml/src/stats/index.xml index d46c997b..d925ec00 100644 --- a/doc/coverage/xml/src/stats/index.xml +++ b/doc/coverage/xml/src/stats/index.xml @@ -1,5 +1,5 @@ - + diff --git a/doc/coverage/xml/src/stats/perf_counter.dart.gcov.xml b/doc/coverage/xml/src/stats/perf_counter.dart.gcov.xml index 949fca61..4bf08ac4 100644 --- a/doc/coverage/xml/src/stats/perf_counter.dart.gcov.xml +++ b/doc/coverage/xml/src/stats/perf_counter.dart.gcov.xml @@ -1,5 +1,5 @@ - + import 'package:meta/meta.dart'; diff --git a/doc/coverage/xml/src/stats/perf_counter_snapshot.dart.gcov.xml b/doc/coverage/xml/src/stats/perf_counter_snapshot.dart.gcov.xml index 84c87402..1e2e1334 100644 --- a/doc/coverage/xml/src/stats/perf_counter_snapshot.dart.gcov.xml +++ b/doc/coverage/xml/src/stats/perf_counter_snapshot.dart.gcov.xml @@ -1,5 +1,5 @@ - + import 'perf_counter.dart'; diff --git a/doc/coverage/xml/src/stats/worker_stat.dart.gcov.xml b/doc/coverage/xml/src/stats/worker_stat.dart.gcov.xml index adf1d6b1..df9e285b 100644 --- a/doc/coverage/xml/src/stats/worker_stat.dart.gcov.xml +++ b/doc/coverage/xml/src/stats/worker_stat.dart.gcov.xml @@ -1,5 +1,5 @@ - + import 'package:meta/meta.dart'; diff --git a/doc/coverage/xml/src/tokens/_cancelation_token_ref.dart.gcov.xml b/doc/coverage/xml/src/tokens/_cancelation_token_ref.dart.gcov.xml index 8c0c3606..dff84c1c 100644 --- a/doc/coverage/xml/src/tokens/_cancelation_token_ref.dart.gcov.xml +++ b/doc/coverage/xml/src/tokens/_cancelation_token_ref.dart.gcov.xml @@ -1,5 +1,5 @@ - + import 'dart:async'; diff --git a/doc/coverage/xml/src/tokens/_squadron_cancelation_token.dart.gcov.xml b/doc/coverage/xml/src/tokens/_squadron_cancelation_token.dart.gcov.xml index 0434ecda..85023909 100644 --- a/doc/coverage/xml/src/tokens/_squadron_cancelation_token.dart.gcov.xml +++ b/doc/coverage/xml/src/tokens/_squadron_cancelation_token.dart.gcov.xml @@ -1,5 +1,5 @@ - + import 'dart:async'; diff --git a/doc/coverage/xml/src/tokens/index.xml b/doc/coverage/xml/src/tokens/index.xml index bf8df6c4..c8895c35 100644 --- a/doc/coverage/xml/src/tokens/index.xml +++ b/doc/coverage/xml/src/tokens/index.xml @@ -1,5 +1,5 @@ - + diff --git a/doc/coverage/xml/src/typedefs.dart.gcov.xml b/doc/coverage/xml/src/typedefs.dart.gcov.xml index 8c74b3d1..7ab24e32 100644 --- a/doc/coverage/xml/src/typedefs.dart.gcov.xml +++ b/doc/coverage/xml/src/typedefs.dart.gcov.xml @@ -1,5 +1,5 @@ - + import 'dart:async'; diff --git a/doc/coverage/xml/src/worker/index.xml b/doc/coverage/xml/src/worker/index.xml index a37114d9..dc3b1ed1 100644 --- a/doc/coverage/xml/src/worker/index.xml +++ b/doc/coverage/xml/src/worker/index.xml @@ -1,5 +1,5 @@ - + diff --git a/doc/coverage/xml/src/worker/worker.dart.gcov.xml b/doc/coverage/xml/src/worker/worker.dart.gcov.xml index b936cc32..4994e0e5 100644 --- a/doc/coverage/xml/src/worker/worker.dart.gcov.xml +++ b/doc/coverage/xml/src/worker/worker.dart.gcov.xml @@ -1,5 +1,5 @@ - + import 'dart:async'; diff --git a/doc/coverage/xml/src/worker/worker_channel.dart.gcov.xml b/doc/coverage/xml/src/worker/worker_channel.dart.gcov.xml index 61ab7360..dba34f02 100644 --- a/doc/coverage/xml/src/worker/worker_channel.dart.gcov.xml +++ b/doc/coverage/xml/src/worker/worker_channel.dart.gcov.xml @@ -1,5 +1,5 @@ - + import 'dart:async'; diff --git a/doc/coverage/xml/src/worker/worker_message.dart.gcov.xml b/doc/coverage/xml/src/worker/worker_message.dart.gcov.xml index f0268fc0..f71497f2 100644 --- a/doc/coverage/xml/src/worker/worker_message.dart.gcov.xml +++ b/doc/coverage/xml/src/worker/worker_message.dart.gcov.xml @@ -1,5 +1,5 @@ - + import 'package:meta/meta.dart'; @@ -53,17 +53,17 @@ void unwrapTravelTime() { - + final ts = (data[_$traveltime] as num?)?.toInt(); - + - + if (ts != null) { - + - + data[_$traveltime] = microsecTimeStamp() - ts; - + } diff --git a/doc/coverage/xml/src/worker/worker_request.dart.gcov.xml b/doc/coverage/xml/src/worker/worker_request.dart.gcov.xml index 4bee9ae9..c45409f9 100644 --- a/doc/coverage/xml/src/worker/worker_request.dart.gcov.xml +++ b/doc/coverage/xml/src/worker/worker_request.dart.gcov.xml @@ -1,5 +1,5 @@ - + import 'package:meta/meta.dart'; diff --git a/doc/coverage/xml/src/worker/worker_response.dart.gcov.xml b/doc/coverage/xml/src/worker/worker_response.dart.gcov.xml index bcde4f95..b495c461 100644 --- a/doc/coverage/xml/src/worker/worker_response.dart.gcov.xml +++ b/doc/coverage/xml/src/worker/worker_response.dart.gcov.xml @@ -1,5 +1,5 @@ - + import 'dart:async'; @@ -186,13 +186,13 @@ /// Special [WorkerResponse] message to indicate the end of a stream. - + static WorkerResponse closeStream() => WorkerResponse._([ - + - + microsecTimeStamp(), // 0 - travel time - + null, // 1 - result @@ -215,9 +215,9 @@ /// Flag indicating the end of the [Stream]ing operation. - + bool get endOfStream => data[_$endOfStream]; - + @@ -225,9 +225,9 @@ /// The [WorkerResponse] exception, if any. - + SquadronException? get error => data[_$error]; - + @@ -238,17 +238,17 @@ /// [WorkerResponse] contains an error, an the [error] exception is thrown. - + dynamic get result { - + final err = error; - + if (err != null) { - + throw err; @@ -256,16 +256,16 @@ } else { - + return data[_$result]; - + } - + } - + } @@ -306,21 +306,21 @@ /// used for log messages only). - + bool unwrapInPlace(Channel channel) { - + unwrapTravelTime(); - + final log = _LogEventSerializationExt.deserialize(data[_$log]); - + - + if (log != null) { - + channel.logger?.log(log.level, log.message, @@ -337,24 +337,24 @@ } else { - + data[_$error] = channel.exceptionManager.deserialize(data[_$error]); - + - + data[_$endOfStream] ??= false; - + - + return true; - + } - + } - + @@ -395,13 +395,13 @@ - + static WorkerResponse from(List data) { - + - + if (data.length != 5) { - + throw SquadronErrorExt.create('Invalid worker response'); @@ -409,13 +409,13 @@ } - + return WorkerResponse._(data); - + - + } - + } diff --git a/doc/coverage/xml/src/worker_service.dart.gcov.xml b/doc/coverage/xml/src/worker_service.dart.gcov.xml index bc8019d2..eb788cec 100644 --- a/doc/coverage/xml/src/worker_service.dart.gcov.xml +++ b/doc/coverage/xml/src/worker_service.dart.gcov.xml @@ -1,5 +1,5 @@ - + import 'dart:async'; @@ -120,13 +120,13 @@ /// Empty command handlers map. - + static final Map<int, CommandHandler> noOperations = - + - + Map<int, CommandHandler>.unmodifiable(const {}); - + }