ccia_code_samples icon indicating copy to clipboard operation
ccia_code_samples copied to clipboard

Listing 9.6: the local_work_queue is always nullptr

Open Chen-Xuming opened this issue 3 years ago • 1 comments

In the function worker_thread(), "local_work_queue" call reset() and then it's not NULL. However, in the function submit(), this variable is always nullptr, so the tasks are pushed into global queue. Why?

Chen-Xuming avatar Sep 04 '22 12:09 Chen-Xuming

My opinion: submit() is called in the main thread, but work_thread() is running in the sub-thread, so their thread_local variable "local_work_queue" are different. Therefore, the condition if(local_work_queue) is always false.

Chen-Xuming avatar Sep 04 '22 13:09 Chen-Xuming