]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
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> | |
9f95a23c | 13 | Threads<I>::Threads(CephContext *cct) { |
7c673cae | 14 | thread_pool = new ThreadPool(cct, "Journaler::thread_pool", "tp_journal", |
11fdf7f2 | 15 | cct->_conf.get_val<uint64_t>("rbd_op_threads"), |
181888fb | 16 | "rbd_op_threads"); |
7c673cae FG |
17 | thread_pool->start(); |
18 | ||
19 | work_queue = new ContextWQ("Journaler::work_queue", | |
11fdf7f2 | 20 | cct->_conf.get_val<uint64_t>("rbd_op_thread_timeout"), |
181888fb | 21 | thread_pool); |
7c673cae FG |
22 | |
23 | timer = new SafeTimer(cct, timer_lock, true); | |
24 | timer->init(); | |
25 | } | |
26 | ||
27 | template <typename I> | |
28 | Threads<I>::~Threads() { | |
29 | { | |
9f95a23c | 30 | std::lock_guard timer_locker{timer_lock}; |
7c673cae FG |
31 | timer->shutdown(); |
32 | } | |
33 | delete timer; | |
34 | ||
35 | work_queue->drain(); | |
36 | delete work_queue; | |
37 | ||
38 | thread_pool->stop(); | |
39 | delete thread_pool; | |
40 | } | |
41 | ||
42 | } // namespace mirror | |
43 | } // namespace rbd | |
44 | ||
45 | template class rbd::mirror::Threads<librbd::ImageCtx>; |