From: Sage Weil Date: Mon, 22 Jul 2013 22:19:40 +0000 (-0700) Subject: client: add Context*-based wait_on_list/signal_context_list helpers X-Git-Tag: v0.67-rc2~13 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=3207542055416faae4111ea1285375a136d0e758;p=ceph.git client: add Context*-based wait_on_list/signal_context_list helpers 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 Reviewed-by: Greg Farnum --- diff --git a/src/client/Client.cc b/src/client/Client.cc index eb7502c1530c..7e7fa63c94f3 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -2607,6 +2607,24 @@ void Client::signal_cond_list(list& ls) (*it)->Signal(); } +void Client::wait_on_context_list(list& 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& ls) +{ + while (!ls.empty()) { + ls.front()->complete(0); + ls.pop_front(); + } +} + void Client::wake_inode_waiters(MetaSession *s) { xlist::iterator iter = s->caps.begin(); diff --git a/src/client/Client.h b/src/client/Client.h index 96e8937f287d..ade0b8f29c84 100644 --- a/src/client/Client.h +++ b/src/client/Client.h @@ -344,6 +344,9 @@ protected: void wait_on_list(list& ls); void signal_cond_list(list& ls); + void wait_on_context_list(list& ls); + void signal_context_list(list& ls); + // -- metadata cache stuff // decrease inode ref. delete if dangling.