11 #ifndef smtk_resource_Lock_h
12 #define smtk_resource_Lock_h
14 #include "smtk/CoreExports.h"
16 #include <condition_variable>
45 SMTKCORE_EXPORT
Lock();
47 Lock& operator=(
const Lock&) =
delete;
49 SMTKCORE_EXPORT
void lock(LockType);
50 SMTKCORE_EXPORT
bool tryLock(LockType);
51 SMTKCORE_EXPORT
void unlock(LockType);
53 SMTKCORE_EXPORT LockType state()
const;
57 std::condition_variable m_readerCondition;
58 std::condition_variable m_writerCondition;
59 std::size_t m_activeReaders{ 0 };
60 std::size_t m_waitingWriters{ 0 };
61 std::size_t m_activeWriters{ 0 };
116 SMTKCORE_EXPORT
static std::unique_ptr<ScopedLockSetGuard> Block(
117 const std::set<std::shared_ptr<Resource>>& readLockResources,
118 const std::set<std::shared_ptr<Resource>>& writeLockResources);
120 SMTKCORE_EXPORT
static std::unique_ptr<ScopedLockSetGuard> Try(
121 const std::set<std::shared_ptr<Resource>>& readLockResources,
122 const std::set<std::shared_ptr<Resource>>& writeLockResources);
126 const std::set<std::shared_ptr<Resource>>& readLockResources,
127 const std::set<std::shared_ptr<Resource>>& writeLockResources);
129 std::set<ScopedLockGuard> m_guards;
135 #endif // smtk_resource_Lock_h