mirror of
https://github.com/wolfpld/tracy
synced 2025-04-29 12:23:53 +00:00
Add deadlock test.
This commit is contained in:
parent
a5736a9c1b
commit
73cbd7dc3a
@ -225,6 +225,23 @@ void OnlyMemory()
|
|||||||
new int;
|
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()
|
int main()
|
||||||
{
|
{
|
||||||
auto t1 = std::thread( TestFunction );
|
auto t1 = std::thread( TestFunction );
|
||||||
@ -247,6 +264,8 @@ int main()
|
|||||||
auto t18 = std::thread( SharedWrite2 );
|
auto t18 = std::thread( SharedWrite2 );
|
||||||
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 t22 = std::thread( DeadlockTest2 );
|
||||||
|
|
||||||
tracy::SetThreadName( t1, "First thread" );
|
tracy::SetThreadName( t1, "First thread" );
|
||||||
tracy::SetThreadName( t2, "Second thread" );
|
tracy::SetThreadName( t2, "Second thread" );
|
||||||
@ -268,6 +287,8 @@ int main()
|
|||||||
tracy::SetThreadName( t18, "Shared write 2" );
|
tracy::SetThreadName( t18, "Shared write 2" );
|
||||||
tracy::SetThreadName( t19, "Callstack time" );
|
tracy::SetThreadName( t19, "Callstack time" );
|
||||||
tracy::SetThreadName( t20, "Only memory" );
|
tracy::SetThreadName( t20, "Only memory" );
|
||||||
|
tracy::SetThreadName( t21, "Deadlock test 1" );
|
||||||
|
tracy::SetThreadName( t22, "Deadlock test 2" );
|
||||||
|
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user