]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
tools: templatize create_rados_callback
authorshangdehao1 <dehao.shang@intel.com>
Sun, 17 Feb 2019 20:30:28 +0000 (04:30 +0800)
committerYuan Zhou <yuan.zhou@intel.com>
Thu, 21 Mar 2019 16:16:29 +0000 (00:16 +0800)
Also cleanup unused template codes

Signed-off-by: Dehao Shang <dehao.shang@intel.com>
src/tools/immutable_object_cache/CMakeLists.txt
src/tools/immutable_object_cache/Utils.cc [deleted file]
src/tools/immutable_object_cache/Utils.h

index f4c165b95a2ca1509aff7285c47d3ded07da4819..56a5f73109cf41ec521d7f9775e6be8724094c7c 100644 (file)
@@ -5,7 +5,6 @@ set(ceph_immutable_object_cache_files
   CacheClient.cc
   CacheSession.cc
   SimplePolicy.cc
-  Utils.cc
   Types.cc
   )
 add_library(ceph_immutable_object_cache_lib STATIC ${ceph_immutable_object_cache_files})
diff --git a/src/tools/immutable_object_cache/Utils.cc b/src/tools/immutable_object_cache/Utils.cc
deleted file mode 100644 (file)
index 28b9b0b..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
-// vim: ts=8 sw=2 smarttab
-
-#include "Utils.h"
-
-#define dout_subsys ceph_subsys_immutable_obj_cache
-#undef dout_prefix
-#define dout_prefix *_dout << "ceph::cache::Utils: " << __func__ << ": "
-
-namespace ceph {
-namespace immutable_obj_cache {
-
-librados::AioCompletion *create_rados_callback(Context *on_finish) {
-  return create_rados_callback<Context, &Context::complete>(on_finish);
-}
-
-} // namespace immutable_obj_cache
-} // namespace ceph
index d3fb8d92cd46bbdc7808f6cac099f620bc49fd3a..daa2bffda8bf9efcc09ad1abc0ad9d728d58051d 100644 (file)
@@ -12,11 +12,6 @@ namespace ceph {
 namespace immutable_obj_cache {
 namespace detail {
 
-template <typename T>
-void rados_callback(rados_completion_t c, void *arg) {
-  reinterpret_cast<T*>(arg)->complete(rados_aio_get_return_value(c));
-}
-
 template <typename T, void(T::*MF)(int)>
 void rados_callback(rados_completion_t c, void *arg) {
   T *obj = reinterpret_cast<T*>(arg);
@@ -24,90 +19,14 @@ void rados_callback(rados_completion_t c, void *arg) {
   (obj->*MF)(r);
 }
 
-template <typename T, Context*(T::*MF)(int*), bool destroy>
-void rados_state_callback(rados_completion_t c, void *arg) {
-  T *obj = reinterpret_cast<T*>(arg);
-  int r = rados_aio_get_return_value(c);
-  Context *on_finish = (obj->*MF)(&r);
-  if (on_finish != nullptr) {
-    on_finish->complete(r);
-    if (destroy) {
-      delete obj;
-    }
-  }
-}
-
-template <typename T, void (T::*MF)(int)>
-class C_CallbackAdapter : public Context {
-  T *obj;
-public:
-  C_CallbackAdapter(T *obj) : obj(obj) {
-  }
-
-protected:
-  void finish(int r) override {
-    (obj->*MF)(r);
-  }
-};
-
-template <typename T, Context*(T::*MF)(int*), bool destroy>
-class C_StateCallbackAdapter : public Context {
-  T *obj;
-public:
-  C_StateCallbackAdapter(T *obj) : obj(obj){
-  }
-
-protected:
-  void complete(int r) override {
-    Context *on_finish = (obj->*MF)(&r);
-    if (on_finish != nullptr) {
-      on_finish->complete(r);
-      if (destroy) {
-        delete obj;
-      }
-    }
-    Context::complete(r);
-  }
-  void finish(int r) override {
-  }
-};
-
-template <typename WQ>
-struct C_AsyncCallback : public Context {
-  WQ *op_work_queue;
-  Context *on_finish;
-
-  C_AsyncCallback(WQ *op_work_queue, Context *on_finish)
-    : op_work_queue(op_work_queue), on_finish(on_finish) {
-  }
-  void finish(int r) override {
-    op_work_queue->queue(on_finish, r);
-  }
-};
-
 } // namespace detail
 
-
-librados::AioCompletion *create_rados_callback(Context *on_finish);
-
-template <typename T>
-librados::AioCompletion *create_rados_callback(T *obj) {
-  return librados::Rados::aio_create_completion(
-    obj, &detail::rados_callback<T>, nullptr);
-}
-
-template <typename T, void(T::*MF)(int)>
+template <typename T, void(T::*MF)(int)=&T::complete>
 librados::AioCompletion *create_rados_callback(T *obj) {
   return librados::Rados::aio_create_completion(
     obj, &detail::rados_callback<T, MF>, nullptr);
 }
 
-template <typename T, Context*(T::*MF)(int*), bool destroy=true>
-librados::AioCompletion *create_rados_callback(T *obj) {
-  return librados::Rados::aio_create_completion(
-    obj, &detail::rados_state_callback<T, MF, destroy>, nullptr);
-}
-
 } // namespace immutable_obj_cache
 } // namespace ceph
 #endif