[+] IRWLock::CheckSelfThreadIsWriter
This commit is contained in:
parent
5ec28735ed
commit
43583a1748
@ -13,7 +13,8 @@ namespace Aurora::Threading::Primitives
|
|||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @brief Returns a complete IWaitable interface for reantrant access to the protected resources.
|
* @brief Returns a complete IWaitable interface for reantrant access to the protected resources.
|
||||||
* Once a thread takes exclusive access of the resource, only it shall pass read
|
* Once a thread takes exclusive access of the resource, only it shall pass read. Noting this
|
||||||
|
* is critical section behaviour, not mutex behaviour.
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
virtual IWaitable *AsReadable() = 0;
|
virtual IWaitable *AsReadable() = 0;
|
||||||
@ -39,12 +40,19 @@ namespace Aurora::Threading::Primitives
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
virtual bool DowngradeWriteToRead() = 0;
|
virtual bool DowngradeWriteToRead() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Checks if the current thread has acquired a critical-section lock on the mutually exclusive resource
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
virtual bool CheckSelfThreadIsWriter() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Allows AsReadable entrancy as AsWritable lock
|
/// Allows AsReadable() holder entrancy as AsWritable() lock
|
||||||
|
/// Check CheckSelfThreadIsWriter() before any lock guards, if non-reentrant mutual exclusion is desired.
|
||||||
AUKN_SHARED_SOO_NCM(RWLock, IRWLock, kPrimitiveSizeRWLock);
|
AUKN_SHARED_SOO_NCM(RWLock, IRWLock, kPrimitiveSizeRWLock);
|
||||||
|
|
||||||
/// Allows AsWritable reentrancy, and allows AsReadable entrancy as AsWritable lock
|
/// Allows AsWritable() holder reentrancy, and allows AsReadable() holder entrancy as AsWritable() lock
|
||||||
AUKN_SHARED_SOO_NCM(RWRenterableLock, IRWLock, kPrimitiveSizeRWLock);
|
AUKN_SHARED_SOO_NCM(RWRenterableLock, IRWLock, kPrimitiveSizeRWLock);
|
||||||
|
|
||||||
}
|
}
|
@ -934,6 +934,13 @@ namespace Aurora::Threading::Primitives
|
|||||||
return &this->write_;
|
return &this->write_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<bool bIsWriteRecursionAllowed>
|
||||||
|
bool RWLockImpl<bIsWriteRecursionAllowed>::CheckSelfThreadIsWriter()
|
||||||
|
{
|
||||||
|
return this->reentrantWriteLockHandle_ == GetThreadCookie();
|
||||||
|
}
|
||||||
|
|
||||||
AUKN_SYM IRWLock *RWLockNew()
|
AUKN_SYM IRWLock *RWLockNew()
|
||||||
{
|
{
|
||||||
return _new RWLockImpl<false>();
|
return _new RWLockImpl<false>();
|
||||||
|
@ -90,6 +90,8 @@ namespace Aurora::Threading::Primitives
|
|||||||
IWaitable *AsReadable() override;
|
IWaitable *AsReadable() override;
|
||||||
IWaitable *AsWritable() override;
|
IWaitable *AsWritable() override;
|
||||||
|
|
||||||
|
bool CheckSelfThreadIsWriter() override;
|
||||||
|
|
||||||
auline ConditionVariableInternal &GetCondition();
|
auline ConditionVariableInternal &GetCondition();
|
||||||
auline ConditionVariableInternal &GetConditionWriter();
|
auline ConditionVariableInternal &GetConditionWriter();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user