pthread conditional variable

后端 未结 5 1521
借酒劲吻你
借酒劲吻你 2020-12-14 05:16

I\'m implementing a thread with a queue of tasks. As soon as as the first task is added to the queue the thread starts running it.

Should I use pthread condition var

5条回答
  •  温柔的废话
    2020-12-14 05:47

    No effects.

    If you check how pthread_condt_signal is implemented, the condt uses several counters to check whether there are any waiting threads to wake up. e.g., glibc-nptl

     /* Are there any waiters to be woken?  */
     if (cond->__data.__total_seq > cond->__data.__wakeup_seq){
        ...
     }
    

提交回复
热议问题