From 73cbd7dc3a135490156f7222e1885e0732e2e66f Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Wed, 9 Jan 2019 20:15:45 +0100 Subject: [PATCH] Add deadlock test. --- test/test.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/test/test.cpp b/test/test.cpp index b81fca90..6a8582ec 100644 --- a/test/test.cpp +++ b/test/test.cpp @@ -225,6 +225,23 @@ void OnlyMemory() new int; } +static TracyLockable( std::mutex, deadlockMutex1 ); +static TracyLockable( std::mutex, deadlockMutex2 ); + +void DeadlockTest1() +{ + deadlockMutex1.lock(); + std::this_thread::sleep_for( std::chrono::milliseconds( 100 ) ); + deadlockMutex2.lock(); +} + +void DeadlockTest2() +{ + deadlockMutex2.lock(); + std::this_thread::sleep_for( std::chrono::milliseconds( 100 ) ); + deadlockMutex1.lock(); +} + int main() { auto t1 = std::thread( TestFunction ); @@ -247,6 +264,8 @@ int main() auto t18 = std::thread( SharedWrite2 ); auto t19 = std::thread( CallstackTime ); auto t20 = std::thread( OnlyMemory ); + auto t21 = std::thread( DeadlockTest1 ); + auto t22 = std::thread( DeadlockTest2 ); tracy::SetThreadName( t1, "First thread" ); tracy::SetThreadName( t2, "Second thread" ); @@ -268,6 +287,8 @@ int main() tracy::SetThreadName( t18, "Shared write 2" ); tracy::SetThreadName( t19, "Callstack time" ); tracy::SetThreadName( t20, "Only memory" ); + tracy::SetThreadName( t21, "Deadlock test 1" ); + tracy::SetThreadName( t22, "Deadlock test 2" ); for(;;) {