Lines Matching refs:tctx

140   ThreadContextBase *tctx = QuarantinePop();  in CreateThread()  local
141 if (tctx) { in CreateThread()
142 tid = tctx->tid; in CreateThread()
146 tctx = context_factory_(tid); in CreateThread()
147 threads_.push_back(tctx); in CreateThread()
158 CHECK_NE(tctx, 0); in CreateThread()
161 CHECK_EQ(tctx->status, ThreadStatusInvalid); in CreateThread()
173 tctx->SetCreated(user_id, total_threads_++, detached, in CreateThread()
182 ThreadContextBase *tctx = threads_[tid]; in RunCallbackForEachThreadLocked() local
183 if (tctx == 0) in RunCallbackForEachThreadLocked()
185 cb(tctx, arg); in RunCallbackForEachThreadLocked()
192 ThreadContextBase *tctx = threads_[tid]; in FindThread() local
193 if (tctx != 0 && cb(tctx, arg)) in FindThread()
194 return tctx->tid; in FindThread()
203 ThreadContextBase *tctx = threads_[tid]; in FindThreadContextLocked() local
204 if (tctx != 0 && cb(tctx, arg)) in FindThreadContextLocked()
205 return tctx; in FindThreadContextLocked()
210 static bool FindThreadContextByOsIdCallback(ThreadContextBase *tctx, in FindThreadContextByOsIdCallback() argument
212 return (tctx->os_id == (uptr)arg && tctx->status != ThreadStatusInvalid && in FindThreadContextByOsIdCallback()
213 tctx->status != ThreadStatusDead); in FindThreadContextByOsIdCallback()
223 ThreadContextBase *tctx = threads_[tid]; in SetThreadName() local
224 CHECK_NE(tctx, 0); in SetThreadName()
226 tctx->status); in SetThreadName()
227 tctx->SetName(name); in SetThreadName()
238 ThreadContextBase *tctx = threads_[tid]; in DetachThread() local
239 CHECK_NE(tctx, 0); in DetachThread()
240 if (tctx->status == ThreadStatusInvalid) { in DetachThread()
244 tctx->OnDetached(arg); in DetachThread()
245 if (tctx->status == ThreadStatusFinished) { in DetachThread()
246 if (tctx->user_id) in DetachThread()
247 live_.erase(tctx->user_id); in DetachThread()
248 tctx->SetDead(); in DetachThread()
249 QuarantinePush(tctx); in DetachThread()
251 tctx->detached = true; in DetachThread()
260 ThreadContextBase *tctx = threads_[tid]; in JoinThread() local
261 CHECK_NE(tctx, 0); in JoinThread()
262 if (tctx->status == ThreadStatusInvalid) { in JoinThread()
266 if ((destroyed = tctx->GetDestroyed())) { in JoinThread()
267 if (tctx->user_id) in JoinThread()
268 live_.erase(tctx->user_id); in JoinThread()
269 tctx->SetJoined(arg); in JoinThread()
270 QuarantinePush(tctx); in JoinThread()
287 ThreadContextBase *tctx = threads_[tid]; in FinishThread() local
288 CHECK_NE(tctx, 0); in FinishThread()
289 bool dead = tctx->detached; in FinishThread()
290 ThreadStatus prev_status = tctx->status; in FinishThread()
291 if (tctx->status == ThreadStatusRunning) { in FinishThread()
296 CHECK_EQ(tctx->status, ThreadStatusCreated); in FinishThread()
299 tctx->SetFinished(); in FinishThread()
301 if (tctx->user_id) in FinishThread()
302 live_.erase(tctx->user_id); in FinishThread()
303 tctx->SetDead(); in FinishThread()
304 QuarantinePush(tctx); in FinishThread()
306 tctx->SetDestroyed(); in FinishThread()
314 ThreadContextBase *tctx = threads_[tid]; in StartThread() local
315 CHECK_NE(tctx, 0); in StartThread()
316 CHECK_EQ(ThreadStatusCreated, tctx->status); in StartThread()
317 tctx->SetStarted(os_id, thread_type, arg); in StartThread()
320 void ThreadRegistry::QuarantinePush(ThreadContextBase *tctx) { in QuarantinePush() argument
321 if (tctx->tid == 0) in QuarantinePush()
323 dead_threads_.push_back(tctx); in QuarantinePush()
326 tctx = dead_threads_.front(); in QuarantinePush()
328 CHECK_EQ(tctx->status, ThreadStatusDead); in QuarantinePush()
329 tctx->Reset(); in QuarantinePush()
330 tctx->reuse_count++; in QuarantinePush()
331 if (max_reuse_ > 0 && tctx->reuse_count >= max_reuse_) in QuarantinePush()
333 invalid_threads_.push_back(tctx); in QuarantinePush()
339 ThreadContextBase *tctx = invalid_threads_.front(); in QuarantinePop() local
341 return tctx; in QuarantinePop()
351 auto *tctx = threads_[tid]; in ConsumeThreadUserId() local
352 CHECK_EQ(tctx->user_id, user_id); in ConsumeThreadUserId()
353 tctx->user_id = 0; in ConsumeThreadUserId()
359 ThreadContextBase *tctx = threads_[tid]; in SetThreadUserId() local
360 CHECK_NE(tctx, 0); in SetThreadUserId()
361 CHECK_NE(tctx->status, ThreadStatusInvalid); in SetThreadUserId()
362 CHECK_NE(tctx->status, ThreadStatusDead); in SetThreadUserId()
363 CHECK_EQ(tctx->user_id, 0); in SetThreadUserId()
364 tctx->user_id = user_id; in SetThreadUserId()
365 CHECK(live_.try_emplace(user_id, tctx->tid).second); in SetThreadUserId()
375 for (auto *tctx : threads_) { in OnFork() local
376 if (tctx->tid == tid || !tctx->user_id) in OnFork()
378 CHECK(live_.erase(tctx->user_id)); in OnFork()
379 tctx->user_id = 0; in OnFork()