MCPcopy Create free account
hub / github.com/acl-dev/acl / lock

Method lock

lib_acl_cpp/src/stream/fstream.cpp:212–231  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

210}
211
212bool fstream::lock(bool exclude /* = true */)
213{
214 ACL_FILE_HANDLE fd = file_handle();
215 if (fd == ACL_FILE_INVALID) {
216 logger_error("invalid file handle");
217#ifndef ACL_WINDOWS
218 errno = EBADF;
219#endif
220 return false;
221 }
222
223#ifdef ACL_HAS_FLOCK_LOCK
224 // Use flock mode first when flock is supported by OS.
225 return acl_myflock(fd, ACL_FLOCK_STYLE_FLOCK,
226 exclude ? LOCK_EX : LOCK_SH) == 0;
227#else
228 return acl_myflock(fd, ACL_FLOCK_STYLE_FCNTL,
229 exclude ? ACL_FLOCK_OP_EXCLUSIVE : ACL_FLOCK_OP_SHARED) == 0;
230#endif
231}
232
233bool fstream::try_lock(bool exclude /* = true */)
234{

Callers 15

runMethod · 0.45
mainFunction · 0.45
mainFunction · 0.45
runMethod · 0.45
mainFunction · 0.45
runMethod · 0.45
mainFunction · 0.45
runMethod · 0.45
mainFunction · 0.45
runMethod · 0.45
mainFunction · 0.45
runMethod · 0.45

Calls 1

acl_myflockFunction · 0.85

Tested by

no test coverage detected