withLock<T> method

Future<T> withLock<T>(
  1. Future<T> task()
)

在信号量保护下执行任务

Implementation

Future<T> withLock<T>(Future<T> Function() task) async {
  await acquire();
  try {
    return await task();
  } finally {
    release();
  }
}