std::condition_variable::notify_one() called several times without context switching

后端 未结 1 1301
心在旅途
心在旅途 2021-01-15 05:30

How many waiting threads will wake up in this example:

1st thread:

void wakeUp2Threads()
{
    std::unique_lock lo         


        
1条回答
  •  一整个雨季
    2021-01-15 06:09

    The notify_one call atomically unblocks one thread. That means that when called a second time it can't unblock the same thread as it's no longer blocked.

    This is specified in the standard at section 30.5/3 and 30.5.1/7.

    0 讨论(0)
提交回复
热议问题