From: Jason Dillaman Date: Wed, 8 Apr 2015 20:46:34 +0000 (-0400) Subject: WorkQueue: add new ContextWQ work queue X-Git-Tag: v0.80.11~58^2~11 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=9bf970c1d956c94bc420d874eb83db1f16cf5d44;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 (cherry picked from commit 24a33e977f7b71962adeeb48f75d488a76e70fa9) Conflicts: src/common/WorkQueue.h: trivial resolution --- diff --git a/src/common/WorkQueue.h b/src/common/WorkQueue.h index cbf49a8bb2e5..07aea2de3f63 100644 --- a/src/common/WorkQueue.h +++ b/src/common/WorkQueue.h @@ -433,4 +433,35 @@ 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; +}; + #endif