diff --git a/chaos/common/thread/TLockFreeQueue.h b/chaos/common/thread/TLockFreeQueue.h index 4c0361279d259ed65fbc35c60c716ff5be4ea735..dd18be0a86e26528a2b20ab51806c8c30535b78e 100644 --- a/chaos/common/thread/TLockFreeQueue.h +++ b/chaos/common/thread/TLockFreeQueue.h @@ -102,6 +102,16 @@ class TLockFreeQueue { } return ret; } + int clear(){ + T* ele=NULL; + while(element_queue.pop(ele)){ + if(ele){ + delete ele; + } + size--; + } + return size; + } int wait_and_pop(T& popped_value, int timeout_ms = 0) { if (element_queue.empty()) { ChaosUniqueLock lock(the_mutex);