loadWithIsolate<T> method

Future<T> loadWithIsolate<T>(
  1. Future<T> function()
)

Implementation

Future<T> loadWithIsolate<T>(Future<T> Function() function) async {
  if (_currentIsolates < _maxIsolates) {
    _currentIsolates++;
    return _executeIsolate(function);
  } else {
    final completer = Completer<T>();
    _taskQueue.add(() async {
      final result = await _executeIsolate(function);
      completer.complete(result);
    });
    return completer.future;
  }
}