SMTK  @SMTK_VERSION@
Simulation Modeling Tool Kit
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
smtk::resource::ScopedLockSetGuard Class Reference

A utility for holding multiple lock-guards at once. More...

#include <Lock.h>

Collaboration diagram for smtk::resource::ScopedLockSetGuard:
[legend]

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< ScopedLockSetGuardBlock (const std::set< std::shared_ptr< Resource >> &readLockResources, const std::set< std::shared_ptr< Resource >> &writeLockResources)
 
static SMTKCORE_EXPORT std::unique_ptr< ScopedLockSetGuardTry (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< ScopedLockGuardm_guards
 

Detailed Description

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.


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