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