withSessionLock<T> function
Convenience helper executing action within a session lock.
Binds: FR-056, FR-056a.
Implementation
Future<T> withSessionLock<T>(
String destinationPath,
Future<T> Function() action, {
String? baseDir,
bool Function(int pid)? isPidAlive,
int? currentPid,
}) async {
final lock = await SessionLock.acquire(
destinationPath,
baseDir: baseDir,
isPidAlive: isPidAlive,
currentPid: currentPid,
);
try {
return await action();
} finally {
await lock.release();
}
}