]> git.proxmox.com Git - ceph.git/blob - ceph/src/tools/rbd_mirror/Threads.cc
8c22440a006718c6d9c56afdc93282f1c05c2b9d
[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 "common/WorkQueue.h"
7 #include "librbd/ImageCtx.h"
8
9 namespace rbd {
10 namespace mirror {
11
12 template <typename I>
13 Threads<I>::Threads(CephContext *cct) : timer_lock("Threads::timer_lock") {
14 thread_pool = new ThreadPool(cct, "Journaler::thread_pool", "tp_journal",
15 cct->_conf->rbd_op_threads, "rbd_op_threads");
16 thread_pool->start();
17
18 work_queue = new ContextWQ("Journaler::work_queue",
19 cct->_conf->rbd_op_thread_timeout, thread_pool);
20
21 timer = new SafeTimer(cct, timer_lock, true);
22 timer->init();
23 }
24
25 template <typename I>
26 Threads<I>::~Threads() {
27 {
28 Mutex::Locker timer_locker(timer_lock);
29 timer->shutdown();
30 }
31 delete timer;
32
33 work_queue->drain();
34 delete work_queue;
35
36 thread_pool->stop();
37 delete thread_pool;
38 }
39
40 } // namespace mirror
41 } // namespace rbd
42
43 template class rbd::mirror::Threads<librbd::ImageCtx>;