0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
TableMutatorAsyncCompletionCounter.h
Go to the documentation of this file.
1 /* -*- c++ -*-
2  * Copyright (C) 2007-2015 Hypertable, Inc.
3  *
4  * This file is part of Hypertable.
5  *
6  * Hypertable is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; version 3 of the
9  * License, or any later version.
10  *
11  * Hypertable is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19  * 02110-1301, USA.
20  */
21 
22 #ifndef Hypertable_Lib_TableMutatorAsyncCompletionCounter_h
23 #define Hypertable_Lib_TableMutatorAsyncCompletionCounter_h
24 
25 #include <Common/Time.h>
26 
27 #include <mutex>
28 
29 namespace Hypertable {
30 
40  public:
42 
43  void set(size_t count) {
44  std::lock_guard<std::mutex> lock(m_mutex);
45  m_outstanding = count;
46  m_done = (m_outstanding == 0) ? true : false;
47  m_errors = m_retries = false;
48  }
49 
50  bool decrement() {
51  std::lock_guard<std::mutex> lock(m_mutex);
53  m_outstanding--;
54  if (m_outstanding == 0) {
55  m_done = true;
56  }
57  return m_done;
58  }
59  void set_retries() { std::lock_guard<std::mutex> lock(m_mutex); m_retries = true; }
60 
61  void set_errors() { std::lock_guard<std::mutex> lock(m_mutex); m_errors = true; }
62 
63  bool has_retries() { std::lock_guard<std::mutex> lock(m_mutex); return m_retries; }
64 
65  bool has_errors() { std::lock_guard<std::mutex> lock(m_mutex); return m_errors; }
66 
67  void clear_errors() { std::lock_guard<std::mutex> lock(m_mutex); m_errors = false; }
68 
69  private:
71  size_t m_outstanding {};
72  bool m_done {};
73  bool m_retries {};
74  bool m_errors {};
75  };
76 
77 }
78 
79 #endif // Hypertable_Lib_TableMutatorAsyncCompletionCounter_h
static std::mutex mutex
Definition: Logger.cc:43
Tracks outstanding RangeServer update requests.
#define HT_ASSERT(_e_)
Definition: Logger.h:396
Time related declarations.
Hypertable definitions