I simply need to implement
FTryWriteScopeLock for some of my features these days.
For the moment, the only way to
try get lock is to use
FScopeTryLock, which is based on a
But unfortunately, there is no
try get lock method for
Readers-writer lock in UE4.
Thus I’ve extend the
FRWLock implementation for both Windows and pthreads.
FTryReadScopeLock class like this:
TryWriteLock method to
This shall work for most of non-Windows platform.
MINIMAL_WINDOWS_API bool WINAPI TryAcquireSRWLockExclusive(PSRWLOCK SRWLock);
MINIMAL_WINDOWS_API bool WINAPI TryAcquireSRWLockExclusive(PSRWLOCK SRWLock)
FORCEINLINE bool TryReadLock()
And everything is good to go.