18
18
namespace __sanitizer {
19
19
20
20
ThreadContextBase::ThreadContextBase (u32 tid)
21
- : tid(tid), unique_id(0 ), reuse_count(), os_id(0 ), user_id(0 ),
22
- status (ThreadStatusInvalid), detached(false ),
23
- thread_type(ThreadType::Regular), parent_tid(0 ), next(0 ) {
21
+ : tid(tid),
22
+ unique_id (0 ),
23
+ reuse_count(),
24
+ os_id(0 ),
25
+ user_id(0 ),
26
+ status(ThreadStatusInvalid),
27
+ detached(false ),
28
+ thread_type(ThreadType::Regular),
29
+ parent_tid(0 ),
30
+ next(0 ) {
24
31
name[0 ] = ' \0 ' ;
25
32
atomic_store (&thread_destroyed, 0 , memory_order_release);
26
33
}
@@ -39,8 +46,7 @@ void ThreadContextBase::SetName(const char *new_name) {
39
46
}
40
47
41
48
void ThreadContextBase::SetDead () {
42
- CHECK (status == ThreadStatusRunning ||
43
- status == ThreadStatusFinished);
49
+ CHECK (status == ThreadStatusRunning || status == ThreadStatusFinished);
44
50
status = ThreadStatusDead;
45
51
user_id = 0 ;
46
52
OnDead ();
@@ -68,7 +74,8 @@ void ThreadContextBase::SetFinished() {
68
74
// for a thread that never actually started. In that case the thread
69
75
// should go to ThreadStatusFinished regardless of whether it was created
70
76
// as detached.
71
- if (!detached || status == ThreadStatusCreated) status = ThreadStatusFinished;
77
+ if (!detached || status == ThreadStatusCreated)
78
+ status = ThreadStatusFinished;
72
79
OnFinished ();
73
80
}
74
81
@@ -124,8 +131,10 @@ void ThreadRegistry::GetNumberOfThreads(uptr *total, uptr *running,
124
131
ThreadRegistryLock l (this );
125
132
if (total)
126
133
*total = threads_.size ();
127
- if (running) *running = running_threads_;
128
- if (alive) *alive = alive_threads_;
134
+ if (running)
135
+ *running = running_threads_;
136
+ if (alive)
137
+ *alive = alive_threads_;
129
138
}
130
139
131
140
uptr ThreadRegistry::GetMaxAliveThreads () {
@@ -150,8 +159,10 @@ u32 ThreadRegistry::CreateThread(uptr user_id, bool detached, u32 parent_tid,
150
159
Report (" %s: Thread limit (%u threads) exceeded. Dying.\n " ,
151
160
SanitizerToolName, max_threads_);
152
161
#else
153
- Printf (" race: limit on %u simultaneously alive goroutines is exceeded,"
154
- " dying\n " , max_threads_);
162
+ Printf (
163
+ " race: limit on %u simultaneously alive goroutines is exceeded,"
164
+ " dying\n " ,
165
+ max_threads_);
155
166
#endif
156
167
Die ();
157
168
}
@@ -170,8 +181,7 @@ u32 ThreadRegistry::CreateThread(uptr user_id, bool detached, u32 parent_tid,
170
181
// positives later (e.g. if we join a wrong thread).
171
182
CHECK (live_.try_emplace (user_id, tid).second );
172
183
}
173
- tctx->SetCreated (user_id, total_threads_++, detached,
174
- parent_tid, arg);
184
+ tctx->SetCreated (user_id, total_threads_++, detached, parent_tid, arg);
175
185
return tid;
176
186
}
177
187
@@ -196,8 +206,8 @@ u32 ThreadRegistry::FindThread(FindThreadCallback cb, void *arg) {
196
206
return kInvalidTid ;
197
207
}
198
208
199
- ThreadContextBase *
200
- ThreadRegistry::FindThreadContextLocked ( FindThreadCallback cb, void *arg) {
209
+ ThreadContextBase *ThreadRegistry::FindThreadContextLocked (
210
+ FindThreadCallback cb, void *arg) {
201
211
CheckLocked ();
202
212
for (u32 tid = 0 ; tid < threads_.size (); tid++) {
203
213
ThreadContextBase *tctx = threads_[tid];
@@ -210,7 +220,7 @@ ThreadRegistry::FindThreadContextLocked(FindThreadCallback cb, void *arg) {
210
220
static bool FindThreadContextByOsIdCallback (ThreadContextBase *tctx,
211
221
void *arg) {
212
222
return (tctx->os_id == (uptr)arg && tctx->status != ThreadStatusInvalid &&
213
- tctx->status != ThreadStatusDead);
223
+ tctx->status != ThreadStatusDead);
214
224
}
215
225
216
226
ThreadContextBase *ThreadRegistry::FindThreadContextByOsIDLocked (tid_t os_id) {
0 commit comments