diff options
author | Bartosz Taudul <wolf.pld@gmail.com> | 2019-01-09 22:15:45 +0300 |
---|---|---|
committer | Bartosz Taudul <wolf.pld@gmail.com> | 2019-01-14 20:48:16 +0300 |
commit | 73cbd7dc3a135490156f7222e1885e0732e2e66f (patch) | |
tree | 5815ed99bae8ac34f9ec407a50ac95f206ad08f0 /test | |
parent | a5736a9c1b4180ce93bdbbda5014bda689fcf792 (diff) |
Add deadlock test.
Diffstat (limited to 'test')
-rw-r--r-- | test/test.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
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(;;) { |