Check for shared mutex availability.

This commit is contained in:
Bartosz Taudul 2020-05-13 18:11:48 +02:00
parent ef4c690c32
commit ce15ad763f

View File

@ -1,7 +1,6 @@
#include <chrono> #include <chrono>
#include <mutex> #include <mutex>
#include <thread> #include <thread>
#include <shared_mutex>
#include <stdlib.h> #include <stdlib.h>
#include "../Tracy.hpp" #include "../Tracy.hpp"
#include "../common/TracySystem.hpp" #include "../common/TracySystem.hpp"
@ -185,6 +184,10 @@ void DepthTest()
} }
} }
#ifdef __cpp_lib_shared_mutex
#include <shared_mutex>
static TracySharedLockable( std::shared_mutex, sharedMutex ); static TracySharedLockable( std::shared_mutex, sharedMutex );
void SharedRead1() void SharedRead1()
@ -231,6 +234,8 @@ void SharedWrite2()
} }
} }
#endif
void CaptureCallstack() void CaptureCallstack()
{ {
ZoneScopedS( 10 ); ZoneScopedS( 10 );
@ -286,11 +291,13 @@ int main()
auto t11 = std::thread( DepthTest ); auto t11 = std::thread( DepthTest );
auto t12 = std::thread( RecLock ); auto t12 = std::thread( RecLock );
auto t13 = std::thread( RecLock ); auto t13 = std::thread( RecLock );
#ifdef __cpp_lib_shared_mutex
auto t14 = std::thread( SharedRead1 ); auto t14 = std::thread( SharedRead1 );
auto t15 = std::thread( SharedRead1 ); auto t15 = std::thread( SharedRead1 );
auto t16 = std::thread( SharedRead2 ); auto t16 = std::thread( SharedRead2 );
auto t17 = std::thread( SharedWrite1 ); auto t17 = std::thread( SharedWrite1 );
auto t18 = std::thread( SharedWrite2 ); auto t18 = std::thread( SharedWrite2 );
#endif
auto t19 = std::thread( CallstackTime ); auto t19 = std::thread( CallstackTime );
auto t20 = std::thread( OnlyMemory ); auto t20 = std::thread( OnlyMemory );
auto t21 = std::thread( DeadlockTest1 ); auto t21 = std::thread( DeadlockTest1 );