LCOV - code coverage report
Current view: top level - src/combine_worker - tasks.dart (source / functions) Hit Total Coverage
Test: lcov.info Lines: 37 37 100.0 %
Date: 2022-12-12 00:09:36 Functions: 0 0 -

          Line data    Source code
       1             : import 'dart:async';
       2             : 
       3             : abstract class ExecutableTask<T> {
       4           2 :   const ExecutableTask();
       5             : 
       6             :   FutureOr<T> execute();
       7             : }
       8             : 
       9             : class NoArgsTask<T> extends ExecutableTask<T> {
      10           2 :   const NoArgsTask(this.task);
      11             : 
      12             :   final Task<T> task;
      13             : 
      14           1 :   @override
      15           2 :   FutureOr<T> execute() => task();
      16             : }
      17             : 
      18             : class TaskWithArg<T, Q> extends ExecutableTask<T> {
      19           2 :   const TaskWithArg(this.task, this.argument);
      20             : 
      21             :   final Task1<T, Q> task;
      22             :   final Q argument;
      23             : 
      24           1 :   @override
      25           3 :   FutureOr<T> execute() => task(argument);
      26             : }
      27             : 
      28             : class TaskWith2Args<T, Q, C> extends ExecutableTask<T> {
      29           2 :   const TaskWith2Args(
      30             :     this.task,
      31             :     this.argument,
      32             :     this.argument2,
      33             :   );
      34             : 
      35             :   final Task2<T, Q, C> task;
      36             :   final Q argument;
      37             :   final C argument2;
      38             : 
      39           1 :   @override
      40           4 :   FutureOr<T> execute() => task(argument, argument2);
      41             : }
      42             : 
      43             : class TaskWith3Args<T, Q, C, A> extends ExecutableTask<T> {
      44           1 :   const TaskWith3Args(
      45             :     this.task,
      46             :     this.argument,
      47             :     this.argument2,
      48             :     this.argument3,
      49             :   );
      50             : 
      51             :   final Task3<T, Q, C, A> task;
      52             :   final Q argument;
      53             :   final C argument2;
      54             :   final A argument3;
      55             : 
      56           1 :   @override
      57           5 :   FutureOr<T> execute() => task(argument, argument2, argument3);
      58             : }
      59             : 
      60             : class TaskWith4Args<T, Q, C, A, B> extends ExecutableTask<T> {
      61           1 :   const TaskWith4Args(
      62             :     this.task,
      63             :     this.argument,
      64             :     this.argument2,
      65             :     this.argument3,
      66             :     this.argument4,
      67             :   );
      68             : 
      69             :   final Task4<T, Q, C, A, B> task;
      70             :   final Q argument;
      71             :   final C argument2;
      72             :   final A argument3;
      73             :   final B argument4;
      74             : 
      75           1 :   @override
      76           6 :   FutureOr<T> execute() => task(argument, argument2, argument3, argument4);
      77             : }
      78             : 
      79             : class TaskWith5Args<T, Q, C, A, B, D> extends ExecutableTask<T> {
      80           1 :   const TaskWith5Args(
      81             :     this.task,
      82             :     this.argument,
      83             :     this.argument2,
      84             :     this.argument3,
      85             :     this.argument4,
      86             :     this.argument5,
      87             :   );
      88             : 
      89             :   final Task5<T, Q, C, A, B, D> task;
      90             :   final Q argument;
      91             :   final C argument2;
      92             :   final A argument3;
      93             :   final B argument4;
      94             :   final D argument5;
      95             : 
      96           1 :   @override
      97           2 :   FutureOr<T> execute() => task(
      98           1 :         argument,
      99           1 :         argument2,
     100           1 :         argument3,
     101           1 :         argument4,
     102           1 :         argument5,
     103             :       );
     104             : }
     105             : 
     106             : class TaskWithApplyArgs<T> extends ExecutableTask<T> {
     107           1 :   TaskWithApplyArgs(this.task, this.positionalArguments, this.namedArguments);
     108             : 
     109             :   final TaskApply task;
     110             :   final List<dynamic>? positionalArguments;
     111             :   final Map<Symbol, dynamic>? namedArguments;
     112             : 
     113           1 :   @override
     114             :   FutureOr<T> execute() {
     115           4 :     return Function.apply(task, positionalArguments, namedArguments);
     116             :   }
     117             : }
     118             : 
     119             : class TaskInfo<T> {
     120           1 :   const TaskInfo(this.task, this.resultCompleter);
     121             : 
     122             :   final ExecutableTask<T> task;
     123             :   final Completer<T> resultCompleter;
     124             : }
     125             : 
     126             : abstract class TaskResponse<T> {
     127           1 :   const TaskResponse();
     128             : 
     129             :   void complete(Completer<T> completer);
     130             : }
     131             : 
     132             : class TaskValueResponse<T> extends TaskResponse<T> {
     133           1 :   const TaskValueResponse(this.data);
     134             : 
     135             :   final T data;
     136             : 
     137           1 :   @override
     138             :   void complete(Completer<T> completer) {
     139           1 :     if (!completer.isCompleted) {
     140           2 :       completer.complete(data);
     141             :     }
     142             :   }
     143             : }
     144             : 
     145             : class TaskErrorResponse<T> extends TaskResponse<T> {
     146           1 :   const TaskErrorResponse(this.error, this.stackTrace);
     147             : 
     148             :   final Object error;
     149             :   final StackTrace stackTrace;
     150             : 
     151           1 :   @override
     152             :   void complete(Completer<T> completer) {
     153           1 :     if (!completer.isCompleted) {
     154           3 :       completer.completeError(error, stackTrace);
     155             :     }
     156             :   }
     157             : }
     158             : 
     159             : typedef Task<T> = FutureOr<T> Function();
     160             : typedef Task1<T, Q> = FutureOr<T> Function(Q argument);
     161             : typedef Task2<T, Q, C> = FutureOr<T> Function(Q argument1, C argument2);
     162             : typedef Task3<T, Q, C, A> = FutureOr<T> Function(
     163             :   Q argument1,
     164             :   C argument2,
     165             :   A argument3,
     166             : );
     167             : typedef Task4<T, Q, C, A, B> = FutureOr<T> Function(
     168             :   Q argument1,
     169             :   C argument2,
     170             :   A argument3,
     171             :   B argument4,
     172             : );
     173             : typedef Task5<T, Q, C, A, B, D> = FutureOr<T> Function(
     174             :   Q argument1,
     175             :   C argument2,
     176             :   A argument3,
     177             :   B argument4,
     178             :   D argument5,
     179             : );
     180             : typedef TaskApply<T> = Function;

Generated by: LCOV version 1.16