libdap Updated for version 3.21.1
libdap4 is an implementation of OPeNDAP's DAP protocol.
libdap::mp_lock_guard Class Reference

Lock the cache for writing. Implements RAII for the multi-process write lock for the cache. More...

#include <mp_lock_guard.h>

Collaboration diagram for libdap::mp_lock_guard:
Collaboration graph

Public Types

enum class  operation { read , write }
 

Public Member Functions

 mp_lock_guard ()=delete
 
 mp_lock_guard (const mp_lock_guard &)=delete
 
 mp_lock_guard (int fd, operation op, const mp_lock_guard_logger &logger=mp_lock_guard_logger_default())
 Lock the cache for reading or writing. These are blocking locks.
 
mp_lock_guardoperator= (const mp_lock_guard &)=delete
 
void release ()
 
 ~mp_lock_guard ()
 Unlock the cache. Works for both read and write locks.
 

Static Public Member Functions

static void unlock (int fd, const mp_lock_guard_logger &logger=mp_lock_guard_logger_default())
 

Friends

class mp_lock_guard_test
 

Detailed Description

Lock the cache for writing. Implements RAII for the multi-process write lock for the cache.

This class has an extra method that enables the client to 'release' the lock so that it wil NOT be released when the guard goes out of scope.

See also
mp_read_lock_guard for the corresponding read lock guard.

Definition at line 79 of file mp_lock_guard.h.

Member Enumeration Documentation

◆ operation

Enumerator
read 
write 

Definition at line 81 of file mp_lock_guard.h.

Constructor & Destructor Documentation

◆ mp_lock_guard() [1/3]

libdap::mp_lock_guard::mp_lock_guard ( )
delete

◆ mp_lock_guard() [2/3]

libdap::mp_lock_guard::mp_lock_guard ( const mp_lock_guard & )
delete

◆ mp_lock_guard() [3/3]

libdap::mp_lock_guard::mp_lock_guard ( int fd,
operation op,
const mp_lock_guard_logger & logger = mp_lock_guard_logger_default() )
inline

Lock the cache for reading or writing. These are blocking locks.

Parameters
fdThe file descriptor of the cache control file.
opThe operation to perform. If op is 'write' then the lock is a write lock; if op is 'read' then the lock is a read lock.

Definition at line 130 of file mp_lock_guard.h.

◆ ~mp_lock_guard()

libdap::mp_lock_guard::~mp_lock_guard ( )
inline

Unlock the cache. Works for both read and write locks.

Note
This will not throw an exception if the unlock fails when using the default logger. Also, if the release() method has been called, then this will not unlock the file. It is assumed that some other code will do that using the unlock() method.

Definition at line 142 of file mp_lock_guard.h.

Member Function Documentation

◆ operator=()

mp_lock_guard & libdap::mp_lock_guard::operator= ( const mp_lock_guard & )
delete

◆ release()

void libdap::mp_lock_guard::release ( )
inline

Release control of the lock so that control can exit scope and the lock can be released somewhere else.

Definition at line 160 of file mp_lock_guard.h.

◆ unlock()

static void libdap::mp_lock_guard::unlock ( int fd,
const mp_lock_guard_logger & logger = mp_lock_guard_logger_default() )
inlinestatic

Unlock the cache.

Definition at line 165 of file mp_lock_guard.h.

Friends And Related Symbol Documentation

◆ mp_lock_guard_test

friend class mp_lock_guard_test
friend

Definition at line 115 of file mp_lock_guard.h.


The documentation for this class was generated from the following file: