5
#include "common/debug.h"
6
#define DOUT_SUBSYS finisher
8
#define dout_prefix *_dout << dbeginl << "finisher(" << this << ") "
10
void Finisher::start()
12
finisher_thread.create();
19
finisher_cond.Signal();
20
finisher_lock.Unlock();
21
finisher_thread.join();
24
void Finisher::wait_for_empty()
27
while (!finisher_queue.empty() || finisher_running) {
28
dout(10) << "wait_for_empty waiting" << dendl;
29
finisher_empty_cond.Wait(finisher_lock);
31
dout(10) << "wait_for_empty empty" << dendl;
32
finisher_lock.Unlock();
35
void *Finisher::finisher_thread_entry()
38
dout(10) << "finisher_thread start" << dendl;
40
while (!finisher_stop) {
41
while (!finisher_queue.empty()) {
43
list<pair<Context*,int> > ls_rval;
44
ls.swap(finisher_queue);
45
ls_rval.swap(finisher_queue_rval);
46
finisher_running = true;
47
finisher_lock.Unlock();
48
dout(10) << "finisher_thread doing " << ls << dendl;
50
for (vector<Context*>::iterator p = ls.begin();
57
assert(!ls_rval.empty());
58
Context *c = ls_rval.front().first;
59
c->finish(ls_rval.front().second);
64
dout(10) << "finisher_thread done with " << ls << dendl;
68
finisher_running = false;
70
dout(10) << "finisher_thread empty" << dendl;
71
finisher_empty_cond.Signal();
75
dout(10) << "finisher_thread sleeping" << dendl;
76
finisher_cond.Wait(finisher_lock);
78
finisher_empty_cond.Signal();
80
dout(10) << "finisher_thread stop" << dendl;
81
finisher_lock.Unlock();