]>
git.proxmox.com Git - ceph.git/blob - ceph/src/librbd/AsyncRequest.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3 #ifndef CEPH_LIBRBD_ASYNC_REQUEST_H
4 #define CEPH_LIBRBD_ASYNC_REQUEST_H
6 #include "include/Context.h"
7 #include "include/rados/librados.hpp"
8 #include "include/xlist.h"
9 #include "include/compat.h"
15 template <typename ImageCtxT
= ImageCtx
>
19 AsyncRequest(ImageCtxT
&image_ctx
, Context
*on_finish
);
20 virtual ~AsyncRequest();
22 void complete(int r
) {
23 if (should_complete(r
)) {
24 r
= filter_return_code(r
);
25 finish_and_destroy(r
);
29 virtual void send() = 0;
31 inline bool is_canceled() const {
34 inline void cancel() {
39 ImageCtxT
&m_image_ctx
;
41 librados::AioCompletion
*create_callback_completion();
42 Context
*create_callback_context();
43 Context
*create_async_callback_context();
45 void async_complete(int r
);
47 virtual bool should_complete(int r
) = 0;
48 virtual int filter_return_code(int r
) const {
52 // NOTE: temporary until converted to new state machine format
53 virtual void finish_and_destroy(int r
) {
58 virtual void finish(int r
) {
60 m_on_finish
->complete(r
);
66 typename xlist
<AsyncRequest
<ImageCtxT
> *>::item m_xlist_item
;
69 void finish_request();
74 extern template class librbd::AsyncRequest
<librbd::ImageCtx
>;
76 #endif //CEPH_LIBRBD_ASYNC_REQUEST_H