From: Samuel Just Date: Thu, 28 Feb 2013 18:06:44 +0000 (-0800) Subject: Context: allow C_Contexts to not have a cct, add list_to_context X-Git-Tag: v0.60~78^2~12 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=f6500f59756adc953501bb517f7ec616ab490f60;p=ceph.git Context: allow C_Contexts to not have a cct, add list_to_context This will simplify the SnapMapper implementation. Signed-off-by: Samuel Just --- diff --git a/src/include/Context.h b/src/include/Context.h index a64bb2de5f66..f2416a075d6f 100644 --- a/src/include/Context.h +++ b/src/include/Context.h @@ -67,12 +67,14 @@ inline void finish_contexts(CephContext *cct, std::list& finished, list ls; ls.swap(finished); // swap out of place to avoid weird loops - mydout(cct, 10) << ls.size() << " contexts to finish with " << result << dendl; + if (cct) + mydout(cct, 10) << ls.size() << " contexts to finish with " << result << dendl; for (std::list::iterator it = ls.begin(); it != ls.end(); it++) { Context *c = *it; - mydout(cct,10) << "---- " << c << dendl; + if (cct) + mydout(cct,10) << "---- " << c << dendl; c->complete(result); } } @@ -86,12 +88,14 @@ inline void finish_contexts(CephContext *cct, std::vector& finished, vector ls; ls.swap(finished); // swap out of place to avoid weird loops - mydout(cct,10) << ls.size() << " contexts to finish with " << result << dendl; + 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; - mydout(cct,10) << "---- " << c << dendl; + if (cct) + mydout(cct,10) << "---- " << c << dendl; c->complete(result); } } @@ -125,9 +129,21 @@ public: finish_contexts(cct, contexts, r); } bool empty() { return contexts.empty(); } -}; - + static Context *list_to_context(list &cs) { + if (cs.size() == 0) { + return 0; + } else if (cs.size() == 1) { + Context *c = cs.front(); + cs.clear(); + return c; + } else { + C_Contexts *c(new C_Contexts(0)); + c->take(cs); + return c; + } + } +}; /*