]> git-server-git.apps.pok.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)
committerJason Dillaman <dillaman@redhat.com>
Fri, 24 Jul 2015 13:59:56 +0000 (09:59 -0400)
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)

Conflicts:
src/common/WorkQueue.h: trivial resolution

src/common/WorkQueue.h

index cbf49a8bb2e5fedd812a1e0ca60c03089e854f36..07aea2de3f63ecad90702dbd6263c22d52b40ac5 100644 (file)
@@ -433,4 +433,35 @@ 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;
+};
+
 #endif