MCPcopy Create free account
hub / github.com/apache/trafficserver / thread_loop

Function thread_loop

example/plugins/c-api/thread_pool/thread.cc:152–176  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

150}
151
152void *
153thread_loop(void *arg ATS_UNUSED)
154{
155 /* Infinite loop */
156 for (;;) {
157 /* returns a job or null if no jobs to do */
158 auto job_todo = static_cast<Job *>(remove_from_queue(&job_queue));
159
160 if (job_todo != nullptr) {
161 TSAssert(job_todo->magic == MAGIC_ALIVE);
162
163 /* Simply execute the job function */
164 job_todo->func(job_todo->cont, job_todo->data);
165
166 /* Destroy this job */
167 job_delete(job_todo);
168 } else {
169 /* Sleep until we get awake (probably some work to do) */
170 pthread_mutex_lock(&cond_mutex);
171 pthread_cond_wait(&cond, &cond_mutex);
172 pthread_mutex_unlock(&cond_mutex);
173 }
174 }
175 return nullptr;
176}

Callers

nothing calls this directly

Calls 2

remove_from_queueFunction · 0.85
job_deleteFunction · 0.85

Tested by

no test coverage detected