Blame SOURCES/0012-WorkQueue-add-new-ContextWQ-work-queue.patch

545b23
From 25cc3d73d9a69edd8ae1a67920b48de8a8a6b91f Mon Sep 17 00:00:00 2001
545b23
From: Jason Dillaman <dillaman@redhat.com>
545b23
Date: Wed, 8 Apr 2015 16:46:34 -0400
545b23
Subject: [PATCH 12/22] WorkQueue: add new ContextWQ work queue
545b23
545b23
The queue holds a collection of Context pointers that will
545b23
be completed by the thread pool.
545b23
545b23
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
545b23
(cherry picked from commit 24a33e977f7b71962adeeb48f75d488a76e70fa9)
545b23
(cherry picked from commit f28f18f6aa1930ad2cdbedb5ac7a94aafb49ed2f)
545b23
---
545b23
 src/common/WorkQueue.h | 31 +++++++++++++++++++++++++++++++
545b23
 1 file changed, 31 insertions(+)
545b23
545b23
diff --git a/src/common/WorkQueue.h b/src/common/WorkQueue.h
545b23
index cbf49a8..07aea2d 100644
545b23
--- a/src/common/WorkQueue.h
545b23
+++ b/src/common/WorkQueue.h
545b23
@@ -433,4 +433,35 @@ public:
545b23
   }
545b23
 };
545b23
 
545b23
+class ContextWQ : public ThreadPool::WorkQueueVal<Context *> {
545b23
+public:
545b23
+  ContextWQ(const string &name, time_t ti, ThreadPool *tp)
545b23
+    : ThreadPool::WorkQueueVal<Context *>(name, ti, 0, tp) {}
545b23
+
545b23
+  void queue(Context *ctx) {
545b23
+    ThreadPool::WorkQueueVal<Context *>::queue(ctx);
545b23
+  }
545b23
+
545b23
+protected:
545b23
+  virtual void _enqueue(Context *item) {
545b23
+    _queue.push_back(item);
545b23
+  }
545b23
+  virtual void _enqueue_front(Context *item) {
545b23
+    _queue.push_front(item);
545b23
+  }
545b23
+  virtual bool _empty() {
545b23
+    return _queue.empty();
545b23
+  }
545b23
+  virtual Context *_dequeue() {
545b23
+    Context *item = _queue.front();
545b23
+    _queue.pop_front();
545b23
+    return item;
545b23
+  }
545b23
+  virtual void _process(Context *item) {
545b23
+    item->complete(0);
545b23
+  }
545b23
+private:
545b23
+  list<Context *> _queue;
545b23
+};
545b23
+
545b23
 #endif
545b23
-- 
545b23
2.1.0
545b23