From 0c12f6f2529eb99ebd06b0da107206bb8bcab741 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Thu, 6 Aug 2020 01:00:33 +0800 Subject: [PATCH] common/WorkQueue: remove unused BatchWorkQueue we are using ShardedWQ for handling peering events. and PeeringWQ was the only user of BatchWorkQueue. so let's remove the latter. Signed-off-by: Kefu Chai --- src/common/WorkQueue.h | 79 ------------------------------------------ 1 file changed, 79 deletions(-) diff --git a/src/common/WorkQueue.h b/src/common/WorkQueue.h index 533ce84e91967..8e9ee405d0645 100644 --- a/src/common/WorkQueue.h +++ b/src/common/WorkQueue.h @@ -111,85 +111,6 @@ protected: const std::set &changed) override; public: - /** @brief Work queue that processes several submitted items at once. - * The queue will automatically add itself to the thread pool on construction - * and remove itself on destruction. */ - template - class BatchWorkQueue : public WorkQueue_ { - ThreadPool *pool; - - virtual bool _enqueue(T *) = 0; - virtual void _dequeue(T *) = 0; - virtual void _dequeue(std::list *) = 0; - virtual void _process_finish(const std::list &) {} - - // virtual methods from WorkQueue_ below - void *_void_dequeue() override { - std::list *out(new std::list); - _dequeue(out); - if (!out->empty()) { - return (void *)out; - } else { - delete out; - return 0; - } - } - void _void_process(void *p, TPHandle &handle) override { - _process(*((std::list*)p), handle); - } - void _void_process_finish(void *p) override { - _process_finish(*(std::list*)p); - delete (std::list *)p; - } - - protected: - virtual void _process(const std::list &items, TPHandle &handle) = 0; - - public: - BatchWorkQueue(std::string n, time_t ti, time_t sti, ThreadPool* p) - : WorkQueue_(std::move(n), ti, sti), pool(p) { - pool->add_work_queue(this); - } - ~BatchWorkQueue() override { - pool->remove_work_queue(this); - } - - bool queue(T *item) { - pool->_lock.lock(); - bool r = _enqueue(item); - pool->_cond.notify_one(); - pool->_lock.unlock(); - return r; - } - void dequeue(T *item) { - pool->_lock.lock(); - _dequeue(item); - pool->_lock.unlock(); - } - void clear() { - pool->_lock.lock(); - _clear(); - pool->_lock.unlock(); - } - - void lock() { - pool->lock(); - } - void unlock() { - pool->unlock(); - } - void wake() { - pool->wake(); - } - void _wake() { - pool->_wake(); - } - void drain() { - pool->drain(this); - } - - }; - /** @brief Templated by-value work queue. * Skeleton implementation of a queue that processes items submitted by value. * This is useful if the items are single primitive values or very small objects -- 2.39.5