From: Samuel Just Date: Wed, 12 Jun 2013 20:18:00 +0000 (-0700) Subject: ObjectStore,Context: add register_on_complete X-Git-Tag: v0.67-rc1~138^2~1^2~16 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=daee9dbe89c641876a01e09b97a52fd109cf9def;p=ceph.git ObjectStore,Context: add register_on_complete Signed-off-by: Samuel Just --- diff --git a/src/include/Context.h b/src/include/Context.h index f2416a075d6..e31fca6a426 100644 --- a/src/include/Context.h +++ b/src/include/Context.h @@ -23,6 +23,7 @@ #include #include +#include #define mydout(cct, v) lgeneric_subdout(cct, context, v) @@ -54,6 +55,25 @@ public: void finish(int r) {} }; +template +struct Wrapper : public Context { + Context *to_run; + T val; + Wrapper(Context *to_run, T val) : to_run(to_run), val(val) {} + void finish(int r) { + if (to_run) + to_run->complete(r); + } +}; +struct RunOnDelete { + Context *to_run; + RunOnDelete(Context *to_run) : to_run(to_run) {} + ~RunOnDelete() { + if (to_run) + to_run->complete(0); + } +}; +typedef std::tr1::shared_ptr RunOnDeleteRef; /* * finish and destroy a list of Contexts diff --git a/src/os/ObjectStore.cc b/src/os/ObjectStore.cc index 437549d0b39..eccc90359c5 100644 --- a/src/os/ObjectStore.cc +++ b/src/os/ObjectStore.cc @@ -41,25 +41,6 @@ unsigned ObjectStore::apply_transactions(Sequencer *osr, return r; } -template -struct Wrapper : public Context { - Context *to_run; - T val; - Wrapper(Context *to_run, T val) : to_run(to_run), val(val) {} - void finish(int r) { - if (to_run) - to_run->complete(r); - } -}; -struct RunOnDelete { - Context *to_run; - RunOnDelete(Context *to_run) : to_run(to_run) {} - ~RunOnDelete() { - if (to_run) - to_run->complete(0); - } -}; -typedef std::tr1::shared_ptr RunOnDeleteRef; int ObjectStore::queue_transactions( Sequencer *osr, list& tls, diff --git a/src/os/ObjectStore.h b/src/os/ObjectStore.h index b5e23b16cbe..3bcc6e90f4c 100644 --- a/src/os/ObjectStore.h +++ b/src/os/ObjectStore.h @@ -186,6 +186,11 @@ public: void register_on_applied_sync(Context *c) { on_applied_sync.push_back(c); } + void register_on_complete(Context *c) { + RunOnDeleteRef _complete(new RunOnDelete(c)); + register_on_applied(new ContainerContext(_complete)); + register_on_commit(new ContainerContext(_complete)); + } static void collect_contexts( list &t,