ΒΆstd::error_code tryLockFile(
    int FD,
    std::chrono::milliseconds Timeout = std::
        chrono::duration<long,
                         std::ratio<1, 1000>>(0))

Description

Try to locks the file during the specified time. This function implements advisory locking on entire file. If it returns errc::success , the file is locked by the calling process. Until the process unlocks the file by calling \a unlockFile, all attempts to lock the same file will fail/block. The process that locked the file may assume that none of other processes read or write this file, provided that all processes lock the file prior to accessing its content.

Declared at: llvm/include/llvm/Support/FileSystem.h:1189

Parameters

int FD
The descriptor representing the file to lock.
std::chrono::milliseconds Timeout = std::chrono::duration<long, std::ratio<1, 1000>>(0)
Time in milliseconds that the process should wait before reporting lock failure. Zero value means try to get lock only once.

Returns

errc::success if lock is successfully obtained, errc::no_lock_available if the file cannot be locked, or platform-specific error_code otherwise.