From 4070e1ec08073330dfa4ec4d43e51ea4dfd7e527 Mon Sep 17 00:00:00 2001 From: Jason Dillaman Date: Wed, 8 Apr 2015 16:46:34 -0400 Subject: [PATCH] WorkQueue: add new ContextWQ work queue The queue holds a collection of Context pointers that will be completed by the thread pool. Signed-off-by: Jason Dillaman (cherry picked from commit 24a33e977f7b71962adeeb48f75d488a76e70fa9) (cherry picked from commit a28adfbdd8abc86e7766c303bc610c0c252910f7) --- src/common/WorkQueue.h | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/common/WorkQueue.h b/src/common/WorkQueue.h index 0373d731a93fc..07e9b6f51efd4 100644 --- a/src/common/WorkQueue.h +++ b/src/common/WorkQueue.h @@ -433,6 +433,37 @@ public: } }; +class ContextWQ : public ThreadPool::WorkQueueVal { +public: + ContextWQ(const string &name, time_t ti, ThreadPool *tp) + : ThreadPool::WorkQueueVal(name, ti, 0, tp) {} + + void queue(Context *ctx) { + ThreadPool::WorkQueueVal::queue(ctx); + } + +protected: + virtual void _enqueue(Context *item) { + _queue.push_back(item); + } + virtual void _enqueue_front(Context *item) { + _queue.push_front(item); + } + virtual bool _empty() { + return _queue.empty(); + } + virtual Context *_dequeue() { + Context *item = _queue.front(); + _queue.pop_front(); + return item; + } + virtual void _process(Context *item) { + item->complete(0); + } +private: + list _queue; +}; + class ShardedThreadPool { CephContext *cct; -- 2.39.5