diff options
author | Bartosz Taudul <wolf.pld@gmail.com> | 2017-10-26 00:08:14 +0300 |
---|---|---|
committer | Bartosz Taudul <wolf.pld@gmail.com> | 2017-10-26 00:08:14 +0300 |
commit | 52430d08b736d07ec53f3782fec493454a9da0a3 (patch) | |
tree | 26843374d10bb8c2520688834a7fc05d5f9459fe /test | |
parent | 742e4e2893ce71f67c17df7a33063adc2d249bb5 (diff) |
Add recursive mutex test.
Diffstat (limited to 'test')
-rw-r--r-- | test/test.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/test/test.cpp b/test/test.cpp index f73e329a..17777b03 100644 --- a/test/test.cpp +++ b/test/test.cpp @@ -41,6 +41,7 @@ void ScopeCheck() } static TracyLockable( std::mutex, mutex ); +static TracyLockable( std::recursive_mutex, recmutex ); void Lock1() { @@ -78,6 +79,25 @@ void Lock3() } } +void RecLock() +{ + for(;;) + { + std::this_thread::sleep_for( std::chrono::milliseconds( 7 ) ); + std::lock_guard<LockableBase( std::recursive_mutex )> lock1( recmutex ); + TracyMessageL( "First lock" ); + LockMark( recmutex ); + ZoneScoped; + { + std::this_thread::sleep_for( std::chrono::milliseconds( 3 ) ); + std::lock_guard<LockableBase( std::recursive_mutex )> lock2( recmutex ); + TracyMessageL( "Second lock" ); + LockMark( recmutex ); + std::this_thread::sleep_for( std::chrono::milliseconds( 2 ) ); + } + } +} + void Plot() { unsigned char i = 0; @@ -132,6 +152,8 @@ int main() auto t9 = std::thread( Plot ); auto t10 = std::thread( MessageTest ); auto t11 = std::thread( DepthTest ); + auto t12 = std::thread( RecLock ); + auto t13 = std::thread( RecLock ); tracy::SetThreadName( t1, "First thread" ); tracy::SetThreadName( t2, "Second thread" ); @@ -144,6 +166,8 @@ int main() tracy::SetThreadName( t9, "Plot 2" ); tracy::SetThreadName( t10, "Message test" ); tracy::SetThreadName( t11, "Depth test" ); + tracy::SetThreadName( t12, "Recursive mtx 1" ); + tracy::SetThreadName( t13, "Recursive mtx 2" ); for(;;) { |