blob: d239ff3c4fa2b648ba9297c07da224fa963c0b92 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
#include "common/Finisher.h"
#include "svc_finisher.h"
int RGWSI_Finisher::do_start()
{
finisher = new Finisher(cct);
finisher->start();
return 0;
}
void RGWSI_Finisher::shutdown()
{
if (finalized) {
return;
}
if (finisher) {
finisher->stop();
map<int, ShutdownCB *> cbs;
cbs.swap(shutdown_cbs); /* move cbs out, in case caller unregisetrs */
for (auto& iter : cbs) {
iter.second->call();
}
delete finisher;
}
finalized = true;
}
RGWSI_Finisher::~RGWSI_Finisher()
{
shutdown();
}
void RGWSI_Finisher::register_caller(ShutdownCB *cb, int *phandle)
{
*phandle = ++handles_counter;
shutdown_cbs[*phandle] = cb;
}
void RGWSI_Finisher::unregister_caller(int handle)
{
shutdown_cbs.erase(handle);
}
void RGWSI_Finisher::schedule_context(Context *c)
{
finisher->queue(c);
}
|