]> git.proxmox.com Git - ceph.git/blob - ceph/src/rgw/services/svc_finisher.cc
import quincy beta 17.1.0
[ceph.git] / ceph / src / rgw / services / svc_finisher.cc
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab ft=cpp
3
4 #include "common/Finisher.h"
5
6 #include "svc_finisher.h"
7
8 using namespace std;
9
10 int RGWSI_Finisher::do_start(optional_yield, const DoutPrefixProvider *dpp)
11 {
12 finisher = new Finisher(cct);
13 finisher->start();
14
15 return 0;
16 }
17
18 void RGWSI_Finisher::shutdown()
19 {
20 if (finalized) {
21 return;
22 }
23
24 if (finisher) {
25 finisher->stop();
26
27 map<int, ShutdownCB *> cbs;
28 cbs.swap(shutdown_cbs); /* move cbs out, in case caller unregisetrs */
29 for (auto& iter : cbs) {
30 iter.second->call();
31 }
32 delete finisher;
33 }
34
35 finalized = true;
36 }
37
38 RGWSI_Finisher::~RGWSI_Finisher()
39 {
40 shutdown();
41 }
42
43 void RGWSI_Finisher::register_caller(ShutdownCB *cb, int *phandle)
44 {
45 *phandle = ++handles_counter;
46 shutdown_cbs[*phandle] = cb;
47 }
48
49 void RGWSI_Finisher::unregister_caller(int handle)
50 {
51 shutdown_cbs.erase(handle);
52 }
53
54 void RGWSI_Finisher::schedule_context(Context *c)
55 {
56 finisher->queue(c);
57 }
58