Created
October 22, 2018 12:20
-
-
Save MahatiC/95fc2133127c17d4389d20511c2c3f76 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template <typename I> | |
void ObjectMap<I>::rollback(uint64_t snap_id, Context *on_finish) { | |
ceph_assert(m_image_ctx.snap_lock.is_locked()); | |
ceph_assert(m_image_ctx.object_map_lock.is_wlocked()); | |
using klass = ObjectMap<I>; | |
Context *ctx = create_context_callback<klass>(this, on_finish); | |
object_map::SnapshotRollbackRequest *req = | |
new object_map::SnapshotRollbackRequest(m_image_ctx, snap_id, ctx); | |
req->send(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template <typename T> | |
class C_ContextCallbackAdapter : public Context { | |
T *obj; | |
Context *on_finish; | |
public: | |
C_ContextCallbackAdapter(T *obj, Context *on_finish) | |
: obj(obj), on_finish(on_finish) { | |
obj->get(); | |
} | |
~C_ContextCallbackAdapter() { | |
obj->put(); | |
} | |
protected: | |
void finish(int r) override { | |
on_finish->complete(r); | |
} | |
}; | |
template <typename T> | |
Context *create_context_callback(T *obj, Context *on_finish) { | |
return new detail::C_ContextCallbackAdapter<T>(obj, on_finish); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment