blob: ad1dadeaa2dbff73c65f725cd49d17735ba38193 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
#include <chrono>
#include <mutex>
#include <thread>
#include "../client/Tracy.hpp"
#include "../common/TracySystem.hpp"
void TestFunction()
{
for(;;)
{
std::this_thread::sleep_for( std::chrono::milliseconds( 1 ) );
ZoneScoped;
std::this_thread::sleep_for( std::chrono::milliseconds( 1 ) );
}
}
void ResolutionCheck()
{
for(;;)
{
{
ZoneScoped;
std::this_thread::sleep_for( std::chrono::milliseconds( 1 ) );
}
{
ZoneScoped;
std::this_thread::sleep_for( std::chrono::milliseconds( 1 ) );
}
}
}
void ScopeCheck()
{
for(;;)
{
std::this_thread::sleep_for( std::chrono::milliseconds( 1 ) );
ZoneScoped;
}
}
static TracyLockable( std::mutex, mutex );
void Lock1()
{
for(;;)
{
std::this_thread::sleep_for( std::chrono::milliseconds( 4 ) );
std::lock_guard<LockableBase( std::mutex )> lock( mutex );
LockMark( mutex );
ZoneScoped;
std::this_thread::sleep_for( std::chrono::milliseconds( 4 ) );
}
}
void Lock2()
{
for(;;)
{
std::this_thread::sleep_for( std::chrono::milliseconds( 3 ) );
std::unique_lock<LockableBase( std::mutex )> lock( mutex );
LockMark( mutex );
ZoneScoped;
std::this_thread::sleep_for( std::chrono::milliseconds( 5 ) );
}
}
void Lock3()
{
for(;;)
{
std::this_thread::sleep_for( std::chrono::milliseconds( 1 ) );
std::unique_lock<LockableBase( std::mutex )> lock( mutex );
LockMark( mutex );
ZoneScoped;
std::this_thread::sleep_for( std::chrono::milliseconds( 1 ) );
}
}
int main()
{
auto t1 = std::thread( TestFunction );
auto t2 = std::thread( TestFunction );
auto t3 = std::thread( ResolutionCheck );
auto t4 = std::thread( ScopeCheck );
auto t5 = std::thread( Lock1 );
auto t6 = std::thread( Lock2 );
auto t7 = std::thread( Lock3 );
tracy::SetThreadName( t1, "First thread" );
tracy::SetThreadName( t2, "Second thread" );
tracy::SetThreadName( t3, "Resolution check" );
tracy::SetThreadName( t4, "Scope check" );
tracy::SetThreadName( t5, "Lock 1" );
tracy::SetThreadName( t6, "Lock 2" );
tracy::SetThreadName( t7, "Lock 3" );
for(;;)
{
std::this_thread::sleep_for( std::chrono::milliseconds( 2 ) );
{
ZoneScoped;
std::this_thread::sleep_for( std::chrono::milliseconds( 2 ) );
}
FrameMark;
}
}
|