]> git.proxmox.com Git - ceph.git/blob - ceph/src/tools/rbd_mirror/BaseRequest.h
update sources to ceph Nautilus 14.2.1
[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 #include "include/Context.h"
9
10 namespace rbd {
11 namespace mirror {
12
13 class BaseRequest : public RefCountedObject {
14 public:
15 BaseRequest(const std::string& name, CephContext *cct, Context *on_finish)
16 : RefCountedObject(cct, 1), m_name(name), m_cct(cct),
17 m_on_finish(on_finish) {
18 }
19
20 virtual void send() = 0;
21 virtual void cancel() {}
22
23 protected:
24 virtual void finish(int r) {
25 if (m_cct) {
26 lsubdout(m_cct, rbd_mirror, 20) << m_name << "::finish: r=" << r << dendl;
27 }
28 if (m_on_finish) {
29 m_on_finish->complete(r);
30 }
31 put();
32 }
33
34 private:
35 const std::string m_name;
36 CephContext *m_cct;
37 Context *m_on_finish;
38 };
39
40 } // namespace mirror
41 } // namespace rbd
42
43 #endif // CEPH_RBD_MIRROR_BASE_REQUEST_H