MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RequestTracker.hpp
1 /*
2  Copyright (C) 2003, 2005-2008 MySQL AB
3  All rights reserved. Use is subject to license terms.
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; version 2 of the License.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program; if not, write to the Free Software
16  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18 
19 #ifndef __REQUEST_TRACKER_HPP
20 #define __REQUEST_TRACKER_HPP
21 
22 #include "SafeCounter.hpp"
23 
25 public:
26  RequestTracker(){ init(); }
27 
28  void init() { m_confs.clear(); m_nRefs = 0; }
29 
30  template<typename SignalClass>
31  bool init(SafeCounterManager& mgr,
32  NodeReceiverGroup rg, Uint16 GSN, Uint32 senderData)
33  {
34  init();
35  SafeCounter tmp(mgr, m_sc);
36  return tmp.init<SignalClass>(rg, GSN, senderData);
37  }
38 
39  bool ignoreRef(SafeCounterManager& mgr, Uint32 nodeId)
40  { return m_sc.clearWaitingFor(mgr, nodeId); }
41 
42  bool reportRef(SafeCounterManager& mgr, Uint32 nodeId)
43  { m_nRefs++; return m_sc.clearWaitingFor(mgr, nodeId); }
44 
45  bool reportConf(SafeCounterManager& mgr, Uint32 nodeId)
46  { m_confs.set(nodeId); return m_sc.clearWaitingFor(mgr, nodeId); }
47 
48  bool hasRef() { return m_nRefs != 0; }
49 
50  bool hasConf() { return !m_confs.isclear(); }
51 
52  bool done() { return m_sc.done(); }
53 
54  NdbNodeBitmask m_confs;
55 
56 private:
57  SafeCounterHandle m_sc;
58  Uint8 m_nRefs;
59 };
60 
61 #endif // __REQUEST_TRACKER_HPP