From: Jason Dillaman Date: Wed, 8 Apr 2015 20:46:34 +0000 (-0400) Subject: WorkQueue: add new ContextWQ work queue X-Git-Tag: v9.0.2~116^2~9 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=24a33e977f7b71962adeeb48f75d488a76e70fa9;p=ceph.git 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 --- diff --git a/src/common/WorkQueue.h b/src/common/WorkQueue.h index 0373d731a93..07e9b6f51ef 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;