summaryrefslogtreecommitdiffstats
path: root/src/common/AsyncOpTracker.h
blob: d913032aa56a0af74ee43277a413a890c28b91f9 (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
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab

#ifndef CEPH_ASYNC_OP_TRACKER_H
#define CEPH_ASYNC_OP_TRACKER_H

#include "common/ceph_mutex.h"

struct Context;

class AsyncOpTracker {
public:
  AsyncOpTracker();
  ~AsyncOpTracker();

  void start_op();
  void finish_op();

  void wait_for_ops(Context *on_finish);

  bool empty();

private:
  ceph::mutex m_lock = ceph::make_mutex("AsyncOpTracker::m_lock");
  uint32_t m_pending_ops = 0;
  Context *m_on_finish = nullptr;

};

#endif // CEPH_ASYNC_OP_TRACKER_H