cvRunAsync0<T> function

Future<T> cvRunAsync0<T>(
  1. Pointer<CvStatus> func(
    1. CvCallback_0 callback
    ),
  2. void onComplete(
    1. Completer<T> completer
    )
)

Implementation

Future<T> cvRunAsync0<T>(
  ffi.Pointer<cvg.CvStatus> Function(cvg.CvCallback_0 callback) func,
  void Function(Completer<T> completer) onComplete,
) {
  final completer = Completer<T>();
  late final ffi.NativeCallable<cvg.CvCallback_0Function> ccallback;
  void onResponse() {
    onComplete(completer);
    ccallback.close();
  }

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