A thread's OS-specific TID is assigned after it start running. However, in order to improve the performance of thread creation, the parent thread does not wait for the child thread to start running before Create() returns. Therefore, when the parent thread finishes Create(), the child thread may not have a OS-specific TID (because it has not actually started execution). In order to get the correc
| 164 | // In order to get the correct tid, this method spins until the child |
| 165 | // thread gets the TID. |
| 166 | int64_t tid() const { |
| 167 | int64_t t = base::subtle::Acquire_Load(&tid_); |
| 168 | if (t != PARENT_WAITING_TID) { |
| 169 | return tid_; |
| 170 | } |
| 171 | return WaitForTid(); |
| 172 | } |
| 173 | |
| 174 | // Returns the thread's pthread ID. |
| 175 | pthread_t pthread_id() const { return thread_; } |