From 43af3432f52d217cbe5af02c089fa25d297c589b Mon Sep 17 00:00:00 2001 From: Michal Jarzabek Date: Sat, 21 May 2016 15:46:18 +0100 Subject: [PATCH] osdc/Objecter: move C_TwoContexts class to cc file Signed-off-by: Michal Jarzabek --- src/osdc/Objecter.cc | 34 ++++++++++++++++++++++++++++++++++ src/osdc/Objecter.h | 35 ++--------------------------------- 2 files changed, 36 insertions(+), 33 deletions(-) diff --git a/src/osdc/Objecter.cc b/src/osdc/Objecter.cc index c703488bd33..d51a4523b47 100644 --- a/src/osdc/Objecter.cc +++ b/src/osdc/Objecter.cc @@ -153,6 +153,40 @@ static const char *config_keys[] = { NULL }; +/** + * This is a more limited form of C_Contexts, but that requires + * a ceph_context which we don't have here. + */ +class ObjectOperation::C_TwoContexts : public Context { + Context *first; + Context *second; +public: + C_TwoContexts(Context *first, Context *second) : + first(first), second(second) {} + void finish(int r) { + first->complete(r); + second->complete(r); + first = NULL; + second = NULL; + } + + virtual ~C_TwoContexts() { + delete first; + delete second; + } +}; + +void ObjectOperation::add_handler(Context *extra) { + size_t last = out_handler.size() - 1; + Context *orig = out_handler[last]; + if (orig) { + Context *wrapper = new C_TwoContexts(orig, extra); + out_handler[last] = wrapper; + } else { + out_handler[last] = extra; + } +} + Objecter::OSDSession::unique_completion_lock Objecter::OSDSession::get_lock( object_t& oid) { diff --git a/src/osdc/Objecter.h b/src/osdc/Objecter.h index 612b8fdf186..e12106bce63 100644 --- a/src/osdc/Objecter.h +++ b/src/osdc/Objecter.h @@ -86,43 +86,12 @@ struct ObjectOperation { ops.rbegin()->op.flags = flags; } - /** - * This is a more limited form of C_Contexts, but that requires - * a ceph_context which we don't have here. - */ - class C_TwoContexts : public Context { - Context *first; - Context *second; - public: - C_TwoContexts(Context *first, Context *second) : first(first), - second(second) {} - void finish(int r) { - first->complete(r); - second->complete(r); - first = NULL; - second = NULL; - } - - virtual ~C_TwoContexts() { - delete first; - delete second; - } - }; - + class C_TwoContexts; /** * Add a callback to run when this operation completes, * after any other callbacks for it. */ - void add_handler(Context *extra) { - size_t last = out_handler.size() - 1; - Context *orig = out_handler[last]; - if (orig) { - Context *wrapper = new C_TwoContexts(orig, extra); - out_handler[last] = wrapper; - } else { - out_handler[last] = extra; - } - } + void add_handler(Context *extra); OSDOp& add_op(int op) { int s = ops.size();