MCPcopy Create free account
hub / github.com/Kitware/CMake / Lock

Method Lock

Source/cmFileLock.cxx:43–73  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41}
42
43cmFileLockResult cmFileLock::Lock(std::string const& filename,
44 unsigned long timeout)
45{
46 if (filename.empty()) {
47 // Error is internal since all the directories and file must be created
48 // before actual lock called.
49 return cmFileLockResult::MakeInternal();
50 }
51
52 if (!this->Filename.empty()) {
53 // Error is internal since double-lock must be checked in class
54 // cmFileLockPool by the cmFileLock::IsLocked method.
55 return cmFileLockResult::MakeInternal();
56 }
57
58 this->Filename = filename;
59 cmFileLockResult result = this->OpenFile();
60 if (result.IsOk()) {
61 if (timeout == static_cast<unsigned long>(-1)) {
62 result = this->LockWithoutTimeout();
63 } else {
64 result = this->LockWithTimeout(timeout);
65 }
66 }
67
68 if (!result.IsOk()) {
69 this->Filename.clear();
70 }
71
72 return result;
73}
74
75bool cmFileLock::IsLocked(std::string const& filename) const
76{

Callers 4

doWriteFunction · 0.45
LLVMFuzzerTestOneInputFunction · 0.45
SettingsFileReadMethod · 0.45
AcquireLockMethod · 0.45

Calls 6

OpenFileMethod · 0.95
LockWithoutTimeoutMethod · 0.95
LockWithTimeoutMethod · 0.95
IsOkMethod · 0.80
emptyMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected