cvRunAsync5<T> function

Future<T> cvRunAsync5<T>(
  1. Pointer<CvStatus> func(
    1. CvCallback_5 callback
    ),
  2. void onComplete(
    1. Completer<T> completer,
    2. VoidPtr p,
    3. VoidPtr p1,
    4. VoidPtr p2,
    5. VoidPtr p3,
    6. VoidPtr p4,
    )
)

Implementation

Future<T> cvRunAsync5<T>(
  ffi.Pointer<cvg.CvStatus> Function(cvg.CvCallback_5 callback) func,
  void Function(
    Completer<T> completer,
    VoidPtr p,
    VoidPtr p1,
    VoidPtr p2,
    VoidPtr p3,
    VoidPtr p4,
  ) onComplete,
) {
  final completer = Completer<T>();
  late final ffi.NativeCallable<cvg.CvCallback_5Function> ccallback;
  void onResponse(VoidPtr p, VoidPtr p1, VoidPtr p2, VoidPtr p3, VoidPtr p4) {
    onComplete(completer, p, p1, p2, p3, p4);
    ccallback.close();
  }

  ccallback = ffi.NativeCallable.listener(onResponse);
  throwIfFailed(func(ccallback.nativeFunction));
  return completer.future;
}