8 #ifndef META_OCEAN_BASE_SHARED_LOCK_H
9 #define META_OCEAN_BASE_SHARED_LOCK_H
52 inline const std::wstring& name()
const;
80 inline bool isValid()
const;
86 explicit inline operator bool()
const;
97 #if defined(__APPLE__) || (defined(__linux__) && !defined(_ANDROID))
116 unsigned int localCounter_ = 0u;
119 void* handle_ =
nullptr;
170 return !
name_.empty();
173 inline SharedLock::operator bool()
const
175 return !name_.empty();
179 scopedLock_(sharedLock)
This class implements a recursive lock object.
Definition: Lock.h:31
This class defines a scoped lock object for shared locks.
Definition: SharedLock.h:128
~ScopedSharedLock()
Releases a shared scoped lock object.
Definition: SharedLock.h:184
ScopedSharedLock & operator=(const ScopedSharedLock &scopedSharedLock)=delete
Disabled copy operator.
SharedLock & scopedLock_
Shared lock object to be used for locking.
Definition: SharedLock.h:160
ScopedSharedLock(SharedLock &sharedLock)
Creates a new shared scoped lock object.
Definition: SharedLock.h:178
ScopedSharedLock(const ScopedSharedLock &scopedSharedLock)=delete
Disabled copy constructor.
This class implements a lock shared over individual processes (a system-wide lock).
Definition: SharedLock.h:23
SharedLock & operator=(const SharedLock &sharedLock)=delete
Disabled assign operator.
void lock()
Looks the mutex.
SharedLock(const std::wstring &name)
Creates a new shared lock object by a system unique name of this lock.
void unlock()
Unlocks the mutex.
SharedLock()=default
Creates an invalid shared lock object.
bool createSemaphore()
Creates the semaphore object of this lock.
std::wstring name_
System wide unique name.
Definition: SharedLock.h:110
~SharedLock()
Destructs a shared lock object.
bool tryLock()
Tries to lock the mutex.
Lock localLock_
Local lock object.
Definition: SharedLock.h:113
SharedLock(const SharedLock &sharedLock)=delete
Disabled copy constructor.
bool isValid() const
Returns whether this object is valid and can be used correctly.
Definition: SharedLock.h:168
const std::wstring & name() const
Returns the system wide unique name of this lock.
Definition: SharedLock.h:163
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15