SMTK
@SMTK_VERSION@
Simulation Modeling Tool Kit
|
A utility for holding multiple lock-guards at once. More...
#include <Lock.h>
Public Member Functions | |
ScopedLockSetGuard (const ScopedLockSetGuard &)=delete | |
Do not allow copy-construction or assignment of lock guards. | |
void | operator= (const ScopedLockSetGuard &)=delete |
Static Public Member Functions | |
static SMTKCORE_EXPORT std::unique_ptr< ScopedLockSetGuard > | Block (const std::set< std::shared_ptr< Resource >> &readLockResources, const std::set< std::shared_ptr< Resource >> &writeLockResources) |
static SMTKCORE_EXPORT std::unique_ptr< ScopedLockSetGuard > | Try (const std::set< std::shared_ptr< Resource >> &readLockResources, const std::set< std::shared_ptr< Resource >> &writeLockResources) |
Protected Member Functions | |
ScopedLockSetGuard (const std::set< std::shared_ptr< Resource >> &readLockResources, const std::set< std::shared_ptr< Resource >> &writeLockResources) | |
Protected Attributes | |
std::set< ScopedLockGuard > | m_guards |
A utility for holding multiple lock-guards at once.
This object's static Block() and Try() methods take a set of resources to read-lock and a set of resources to write-lock. The constructor will block until all resources are locked before returning while ScopedLockSetGuard::Try() always return immediately but may return a null pointer (when resource locks are not immediately available).
Note that the public API always returns unique pointers to these objects; you may convert the unique pointer to a shared pointer if you wish (so that resources are held until all shared owners complete), but you may not copy-construct or assign the guard.