allocateNewPage function

Future<void> allocateNewPage(
  1. bool sync,
  2. double newContextId,
  3. int syncBufferSize
)

Implementation

Future<void> allocateNewPage(bool sync, double newContextId, int syncBufferSize) async {
  await waitingSyncTaskComplete(newContextId);

  if (!sync) {
    Completer<void> completer = Completer();
    _AllocateNewPageContext context = _AllocateNewPageContext(completer, newContextId);
    Pointer<NativeFunction<HandleAllocateNewPageResult>> f = Pointer.fromFunction(_handleAllocateNewPageResult);
    _allocateNewPage(newContextId, syncBufferSize, dartContext!.pointer, context, f);
    return completer.future;
  } else {
    Pointer<Void> page = _allocateNewPageSync(newContextId, dartContext!.pointer);
    assert(!_allocatedPages.containsKey(newContextId));
    _allocatedPages[newContextId] = page;
  }
}