]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
WorkQueue: add new ContextWQ work queue
authorJason Dillaman <dillaman@redhat.com>
Wed, 8 Apr 2015 20:46:34 +0000 (16:46 -0400)
committerKen Dreyer <kdreyer@redhat.com>
Wed, 24 Jun 2015 16:40:58 +0000 (10:40 -0600)
The queue holds a collection of Context pointers that will
be completed by the thread pool.

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
(cherry picked from commit 24a33e977f7b71962adeeb48f75d488a76e70fa9)
(cherry picked from commit a28adfbdd8abc86e7766c303bc610c0c252910f7)

src/common/WorkQueue.h

index 0373d731a93fce44eae8972b30732339c9c07850..07e9b6f51efd4e72ed0751e063e9b1a8ac490b32 100644 (file)
@@ -433,6 +433,37 @@ public:
   }
 };
 
+class ContextWQ : public ThreadPool::WorkQueueVal<Context *> {
+public:
+  ContextWQ(const string &name, time_t ti, ThreadPool *tp)
+    : ThreadPool::WorkQueueVal<Context *>(name, ti, 0, tp) {}
+
+  void queue(Context *ctx) {
+    ThreadPool::WorkQueueVal<Context *>::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<Context *> _queue;
+};
+
 class ShardedThreadPool {
 
   CephContext *cct;