19AutoCloseFD openLockFile(
const Path & path,
bool create);
21enum LockType { ltRead, ltWrite };
23void lockFile(
int fd, LockType lockType, NeverAsync = {});
24kj::Promise<Result<void>> lockFileAsync(
int fd, LockType lockType);
31bool unsafeLockFileSingleThreaded(
int fd, LockType lockType, std::chrono::seconds timeout);
32bool tryLockFile(
int fd, LockType lockType);
33void unlockFile(
int fd);
37 friend kj::Promise<Result<PathLock>> lockPathAsync(
const Path & path, std::string_view waitMsg);
39 friend std::optional<PathLock> tryLockPath(
const Path & path);
46 static std::optional<PathLock>
47 lockImpl(
const Path & path, std::string_view waitMsg,
bool wait,
NeverAsync = {});
57kj::Promise<Result<PathLock>> lockPathAsync(
const Path & path, std::string_view waitMsg =
"");
59std::optional<PathLock> tryLockPath(
const Path & path);
61using PathLocks = std::list<PathLock>;
63PathLocks lockPaths(
const PathSet & paths, std::string_view waitMsg =
"", NeverAsync = {});
64std::optional<PathLocks> tryLockPaths(
const PathSet & paths);
73 unlockFile(fd->get());
75 ignoreExceptionInDestructor();
80 std::unique_ptr<AutoCloseFD, Unlocker> fd;
85 static constexpr struct DontWait {
explicit DontWait() =
default; } dont_wait;
90 static kj::Promise<Result<FdLock>>
91 lockAsync(
AutoCloseFD & fd, LockType lockType, std::string_view waitMsg);
93 bool valid()
const {
return bool(fd); }
Definition file-descriptor.hh:42
Definition pathlocks.hh:67
Definition pathlocks.hh:36
This file defines two main structs/classes used in nix error handling.
std::string Path
Definition types.hh:28