From: Patrick Donnelly Date: Tue, 24 Jul 2018 13:47:02 +0000 (-0700) Subject: common: make finish_contexts container agnostic X-Git-Tag: v14.0.1~708^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=9e903af4ea76f0a92212559c1081859e07321811;p=ceph.git common: make finish_contexts container agnostic Signed-off-by: Patrick Donnelly --- diff --git a/src/include/Context.h b/src/include/Context.h index 2dff7302d97..ec3173729ef 100644 --- a/src/include/Context.h +++ b/src/include/Context.h @@ -149,42 +149,18 @@ GenContextURef make_gen_lambda_context(F &&f) { /* * finish and destroy a list of Contexts */ -template -inline void finish_contexts(CephContext *cct, std::list& finished, - int result = 0) +template +inline void finish_contexts(CephContext *cct, C& finished, int result = 0) { if (finished.empty()) return; - list ls; - ls.swap(finished); // swap out of place to avoid weird loops - - if (cct) - mydout(cct, 10) << ls.size() << " contexts to finish with " << result << dendl; - typename std::list::iterator it; - for (it = ls.begin(); it != ls.end(); it++) { - A *c = *it; - if (cct) - mydout(cct,10) << "---- " << c << dendl; - c->complete(result); - } -} - -inline void finish_contexts(CephContext *cct, std::vector& finished, - int result = 0) -{ - if (finished.empty()) - return; - - vector ls; + C ls; ls.swap(finished); // swap out of place to avoid weird loops if (cct) mydout(cct,10) << ls.size() << " contexts to finish with " << result << dendl; - for (std::vector::iterator it = ls.begin(); - it != ls.end(); - it++) { - Context *c = *it; + for (Context* c : ls) { if (cct) mydout(cct,10) << "---- " << c << dendl; c->complete(result);