| 138 | } |
| 139 | |
| 140 | void TaskTracer::set_status(TaskStatus s, TaskMeta* m) { |
| 141 | CHECK_NE(TASK_STATUS_RUNNING, s) << "Use `set_running_status' instead"; |
| 142 | CHECK_NE(TASK_STATUS_END, s) << "Use `set_end_status_unsafe' instead"; |
| 143 | |
| 144 | bool tracing = false; |
| 145 | { |
| 146 | BAIDU_SCOPED_LOCK(m->version_lock); |
| 147 | if (TASK_STATUS_UNKNOWN == m->status && TASK_STATUS_JUMPING == s) { |
| 148 | // Do not update status for jumping when bthread is ending. |
| 149 | return; |
| 150 | } |
| 151 | |
| 152 | tracing = m->traced; |
| 153 | // bthread is scheduled for the first time. |
| 154 | if (TASK_STATUS_READY == s && NULL == m->stack) { |
| 155 | m->status = TASK_STATUS_FIRST_READY; |
| 156 | } else { |
| 157 | m->status = s; |
| 158 | } |
| 159 | if (TASK_STATUS_CREATED == s) { |
| 160 | m->worker_tid = pthread_t{}; |
| 161 | } |
| 162 | } |
| 163 | |
| 164 | // Make sure bthread does not jump stack when it is being traced. |
| 165 | if (tracing && TASK_STATUS_JUMPING == s) { |
| 166 | WaitForTracing(m); |
| 167 | } |
| 168 | } |
| 169 | |
| 170 | void TaskTracer::set_running_status(pthread_t worker_tid, TaskMeta* m) { |
| 171 | BAIDU_SCOPED_LOCK(m->version_lock); |
no outgoing calls