]> git.proxmox.com Git - ceph.git/blob - ceph/src/tools/rbd_mirror/Threads.cc
import ceph quincy 17.2.4
[ceph.git] / ceph / src / tools / rbd_mirror / Threads.cc
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3
4 #include "tools/rbd_mirror/Threads.h"
5 #include "common/Timer.h"
6 #include "librbd/AsioEngine.h"
7 #include "librbd/ImageCtx.h"
8 #include "librbd/asio/ContextWQ.h"
9
10 namespace rbd {
11 namespace mirror {
12
13 template <typename I>
14 Threads<I>::Threads(std::shared_ptr<librados::Rados>& rados) {
15 auto cct = static_cast<CephContext*>(rados->cct());
16 asio_engine = new librbd::AsioEngine(rados);
17 work_queue = asio_engine->get_work_queue();
18
19 timer = new SafeTimer(cct, timer_lock, true);
20 timer->init();
21 }
22
23 template <typename I>
24 Threads<I>::~Threads() {
25 {
26 std::lock_guard timer_locker{timer_lock};
27 timer->shutdown();
28 }
29 delete timer;
30
31 work_queue->drain();
32 delete asio_engine;
33 }
34
35 } // namespace mirror
36 } // namespace rbd
37
38 template class rbd::mirror::Threads<librbd::ImageCtx>;