cameron314 / concurrentqueue

A fast multi-producer, multi-consumer lock-free concurrent queue for C++11
Other
9.52k stars 1.66k forks source link

Is there that kind of API here: call once to clear all data?Even if the caller does not know the number of data in the queue #353

Closed yyf117 closed 1 year ago

cameron314 commented 1 year ago

No. You must repeatedly dequeue, or, if the queue is not being used from any other thread, you can assign an empty temporary:

q = ConcurrentQueue<int>();
yyf117 commented 1 year ago

No. You must repeatedly dequeue, or, if the queue is not being used from any other thread, you can assign an empty temporary:

q = ConcurrentQueue<int>();

thanks.I try to do it like that: // qq0=new moodycamel::ConcurrentQueuecv::UMat; //

//Under certain conditions,try to clear all data elements in queue qq0; UMat r[64];//To clear data at once,i need to set this number larger,such as 64,or 128, ... ,etc. qq0->try_dequeue_bulk(r,64); It doesn't look very convenient to use this way will you update the version and add an API for clearing data at once oneday?

cameron314 commented 1 year ago

No, sorry, see https://github.com/cameron314/concurrentqueue/issues/150#issuecomment-467457890

yyf117 commented 1 year ago

No, sorry, see #150 (comment)

Anyway,thanks again.