BloombergLP::bdls::FilesystemUtil::lock

Acquire a lock for the file with the specified descriptor. If lockWriteFlag is true, acquire an exclusive write lock; otherwise acquire a (possibly) shared read lock. The calling thread will block until the lock is acquired. Return 0 on success, and a non-zero value otherwise. Note that this operation locks the indicated file for use by the current process, but the behavior is unspecified (and platform-dependent) when either attempting to lock descriptor multiple times, or attempting to lock another descriptor referring to the same file, within a single process.

Synopsis

Declared in <bdls_filesystemutil.h>

static
int
lock(
    FileDescriptor descriptor,
    bool lockWriteFlag);