Future withResource()

in lib/pool.dart [120:131]


  Future<T> withResource<T>(FutureOr<T> Function() callback) async {
    if (isClosed) {
      throw StateError('withResource() may not be called on a closed Pool.');
    }

    var resource = await request();
    try {
      return await callback();
    } finally {
      resource.release();
    }
  }