]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
use vector or deque in place of list<Context*> in finisher, ebofs
authorSage Weil <sage@newdream.net>
Thu, 11 Sep 2008 17:41:57 +0000 (10:41 -0700)
committerSage Weil <sage@newdream.net>
Thu, 11 Sep 2008 23:58:27 +0000 (16:58 -0700)
src/common/Finisher.cc
src/common/Finisher.h
src/ebofs/Ebofs.h
src/include/Context.h
src/os/FileJournal.h
src/os/JournalingObjectStore.h

index cd4b4cd570cce3691220408be04442e21b6d35b6..9f00afbe232e66e79790526b709bec131427daff 100644 (file)
@@ -23,7 +23,7 @@ void *Finisher::finisher_thread_entry()
 
   while (!finisher_stop) {
     while (!finisher_queue.empty()) {
-      list<Context*> ls;
+      vector<Context*> ls;
       ls.swap(finisher_queue);
 
       finisher_lock.Unlock();
index e3ef5bf1dec096a08b301492752e28598e521f7c..666ab40d0259373a5d05f01046751ea88fad4532 100644 (file)
@@ -23,7 +23,7 @@ class Finisher {
   Mutex          finisher_lock;
   Cond           finisher_cond;
   bool           finisher_stop;
-  list<Context*> finisher_queue;
+  vector<Context*> finisher_queue;
   
   void *finisher_thread_entry();
 
@@ -40,11 +40,19 @@ class Finisher {
     finisher_cond.Signal();
     finisher_lock.Unlock();
   }
-  void queue(list<Context*>& ls) {
+  void queue(vector<Context*>& ls) {
     finisher_lock.Lock();
-    finisher_queue.splice(finisher_queue.end(), ls);
+    finisher_queue.insert(finisher_queue.end(), ls.begin(), ls.end());
     finisher_cond.Signal();
     finisher_lock.Unlock();
+    ls.clear();
+  }
+  void queue(deque<Context*>& ls) {
+    finisher_lock.Lock();
+    finisher_queue.insert(finisher_queue.end(), ls.begin(), ls.end());
+    finisher_cond.Signal();
+    finisher_lock.Unlock();
+    ls.clear();
   }
   
   void start();
index 3fab714a65d688544e57370a69632c4bf49f2bb4..c3984bf100a7377a4489e8df9ff76e24a6b71e1d 100644 (file)
@@ -56,7 +56,7 @@ protected:
   Cond         sync_cond;
   uint64_t     super_fsid;
 
-  map<version_t, list<Context*> > commit_waiters;
+  map<version_t, vector<Context*> > commit_waiters;
 
   void prepare_super(version_t epoch, bufferptr& bp);
   void write_super(version_t epoch, bufferptr& bp);
index d68fea99ed2d8bc3071d03613304ad5f690d43c9..47bf0fea32bfd6d8489111b92bad27dec953dce1 100644 (file)
@@ -44,9 +44,9 @@ inline void finish_contexts(std::list<Context*>& finished,
   using std::cout;
   using std::endl;
   
-  list<Context*> ls;
   if (finished.empty()) return;
 
+  list<Context*> ls;
   ls.swap(finished); // swap out of place to avoid weird loops
 
   generic_dout(10) << ls.size() << " contexts to finish with " << result << dendl;
@@ -60,6 +60,28 @@ inline void finish_contexts(std::list<Context*>& finished,
   }
 }
 
+inline void finish_contexts(std::vector<Context*>& finished, 
+                            int result = 0)
+{
+  using std::cout;
+  using std::endl;
+  
+  if (finished.empty()) return;
+
+  vector<Context*> ls;
+  ls.swap(finished); // swap out of place to avoid weird loops
+
+  generic_dout(10) << ls.size() << " contexts to finish with " << result << dendl;
+  for (std::vector<Context*>::iterator it = ls.begin(); 
+       it != ls.end(); 
+       it++) {
+    Context *c = *it;
+    generic_dout(10) << "---- " << c << dendl;
+    c->finish(result);
+    delete c;
+  }
+}
+
 class C_NoopContext : public Context {
 public:
   void finish(int r) { }
index 04872d6017cb9ed0774799a920e710caf5d32ac0..3c46397a23dde1298186eb87e117fbf170ed9f87 100644 (file)
@@ -107,10 +107,10 @@ private:
 
   // to be journaled
   list<pair<epoch_t,bufferlist> > writeq;
-  list<Context*> commitq;
+  deque<Context*> commitq;
 
   // being journaled
-  list<Context*> writingq;
+  deque<Context*> writingq;
   
   // write thread
   Mutex write_lock;
index 27cdf9024f339250c45e030cc3a79caadb5e34a6..0600f0a1463c143382826c345c7fb93b55908dbb 100644 (file)
@@ -23,7 +23,7 @@ protected:
   epoch_t super_epoch;
   Journal *journal;
   Finisher finisher;
-  map<version_t, list<Context*> > commit_waiters;
+  map<version_t, vector<Context*> > commit_waiters;
 
   void journal_start() {
     finisher.start();