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

Method try_lock

lib_acl_cpp/src/stream/fstream.cpp:233–252  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

231}
232
233bool fstream::try_lock(bool exclude /* = true */)
234{
235 ACL_FILE_HANDLE fd = file_handle();
236 if (fd == ACL_FILE_INVALID) {
237 logger_error("invalid file handle");
238#ifndef ACL_WINDOWS
239 errno = EBADF;
240#endif
241 return false;
242 }
243
244#ifdef ACL_HAS_FLOCK_LOCK
245 return acl_myflock(fd, ACL_FLOCK_STYLE_FLOCK,
246 exclude ? (LOCK_EX | LOCK_NB) : (LOCK_SH | LOCK_NB)) == 0;
247#else
248 return acl_myflock(fd, ACL_FLOCK_STYLE_FCNTL,
249 exclude ? (ACL_FLOCK_OP_NOWAIT | ACL_FLOCK_OP_EXCLUSIVE)
250 : (ACL_FLOCK_OP_NOWAIT | ACL_FLOCK_OP_SHARED)) == 0;
251#endif
252}
253
254bool fstream::unlock()
255{

Callers 3

runMethod · 0.45
lockMethod · 0.45
buildStatusMethod · 0.45

Calls 1

acl_myflockFunction · 0.85

Tested by

no test coverage detected