]> git.proxmox.com Git - ceph.git/blob - ceph/src/tools/rbd_mirror/BaseRequest.h
update sources to v12.1.0
[ceph.git] / ceph / src / tools / rbd_mirror / BaseRequest.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3
4 #ifndef CEPH_RBD_MIRROR_BASE_REQUEST_H
5 #define CEPH_RBD_MIRROR_BASE_REQUEST_H
6
7 #include "common/RefCountedObj.h"
8
9 namespace rbd {
10 namespace mirror {
11
12 class BaseRequest : public RefCountedObject {
13 public:
14 BaseRequest(const std::string& name, CephContext *cct, Context *on_finish)
15 : RefCountedObject(cct, 1), m_name(name), m_cct(cct),
16 m_on_finish(on_finish) {
17 }
18
19 virtual void send() = 0;
20 virtual void cancel() {}
21
22 protected:
23 virtual void finish(int r) {
24 if (m_cct) {
25 lsubdout(m_cct, rbd_mirror, 20) << m_name << "::finish: r=" << r << dendl;
26 }
27 if (m_on_finish) {
28 m_on_finish->complete(r);
29 }
30 put();
31 }
32
33 private:
34 const std::string m_name;
35 CephContext *m_cct;
36 Context *m_on_finish;
37 };
38
39 } // namespace mirror
40 } // namespace rbd
41
42 #endif // CEPH_RBD_MIRROR_BASE_REQUEST_H