egmkang/green_turtle

In green_turtle/green_turtle/message_queue.h,there should be a condition variable equivalent,is there?

Closed this issue · 3 comments

jinCN commented

I implement a message queue using a mutex and a condition variable.So that in method pop,it will wait until there is at least one item in it.Do you have a equivalent mechanism?

MessageQueue is lock free, so there's not a condition variable to weak up a comsumer.
There's a BlockingQueue (blocking_queue.h) which using mutex, but not supplying condition variable....

because in game sevrer programming, latency and qps are both important. costing a bit of time to exchange qps, i think it's worth to do it.
Sorry for my poor english.

jinCN commented

No sorry,I'm poorer .^_^. So in your opinion,a lock free implementation can't have a condition variable equivalent ,am I right?

yep.
lock free is using busy peeking to solve this problem, not a condition variable, such as while(queue.peek()).