[英]pthread_cond_signal on non-waiting cond_t variable
As a part of my program, i use the command "pthread_cond_signal(cv)". 作为程序的一部分,我使用命令“ pthread_cond_signal(cv)”。
I want to use this line to "free" the waiting cv (but i don't know if this current cv is really waiting now). 我想使用此行“释放”正在等待的简历(但是我不知道当前的简历是否真的正在等待)。
Is it OK to do so also if this cv (a pthread_cond_t variable) is not waiting? 如果此cv(一个pthread_cond_t变量)没有等待,是否也可以这样做? (I mean, pthread_cond_wait was not called upon it before)?
(我的意思是,之前没有调用过pthread_cond_wait)?
What would be the behavior in this case? 在这种情况下会是什么行为?
Thanks a lot. 非常感谢。
From the documentation of pthread_cond_signal : 从pthread_cond_signal的文档中:
The pthread_cond_signal() and pthread_cond_broadcast() functions have no effect if there are no threads currently blocked on cond.
如果cond上当前没有阻塞的线程,则pthread_cond_signal()和pthread_cond_broadcast()函数无效。
So nothing happens if nothing is waiting on the condition. 因此,如果没有任何等待条件,则不会发生任何事情。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.