]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
client: add Context*-based wait_on_list/signal_context_list helpers
authorSage Weil <sage@inktank.com>
Mon, 22 Jul 2013 22:19:40 +0000 (15:19 -0700)
committerSage Weil <sage@inktank.com>
Tue, 23 Jul 2013 23:38:51 +0000 (16:38 -0700)
These are better when the list may need to be deallocated.  Context's are
single-shot and the list is not referenced by the caller.

Signed-off-by: Sage Weil <sage@inktank.com>
Reviewed-by: Greg Farnum <greg@inktank.com>
src/client/Client.cc
src/client/Client.h

index eb7502c1530c962c526adc2cc41fe673476169c9..7e7fa63c94f3c22ed6de4eb74ae748e662b21c24 100644 (file)
@@ -2607,6 +2607,24 @@ void Client::signal_cond_list(list<Cond*>& ls)
     (*it)->Signal();
 }
 
+void Client::wait_on_context_list(list<Context*>& ls)
+{
+  Cond cond;
+  bool done = false;
+  int r;
+  ls.push_back(new C_Cond(&cond, &done, &r));
+  while (!done)
+    cond.Wait(client_lock);
+}
+
+void Client::signal_context_list(list<Context*>& ls)
+{
+  while (!ls.empty()) {
+    ls.front()->complete(0);
+    ls.pop_front();
+  }
+}
+
 void Client::wake_inode_waiters(MetaSession *s)
 {
   xlist<Cap*>::iterator iter = s->caps.begin();
index 96e8937f287d05a5db84593b9083a1436f11ef24..ade0b8f29c84d0f46c5ac1da5d0b8c30c1c4077d 100644 (file)
@@ -344,6 +344,9 @@ protected:
   void wait_on_list(list<Cond*>& ls);
   void signal_cond_list(list<Cond*>& ls);
 
+  void wait_on_context_list(list<Context*>& ls);
+  void signal_context_list(list<Context*>& ls);
+
   // -- metadata cache stuff
 
   // decrease inode ref.  delete if dangling.