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(;;) {