mySQL 5.0.11 sources for tomato
[tomato.git] / release / src / router / mysql / storage / ndb / src / kernel / vm / RequestTracker.hpp
blobd0df66bb37c1d15bd2be142c0f8e021ab7a84a53
1 /* Copyright (c) 2003, 2005, 2006 MySQL AB
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; version 2 of the License.
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 GNU General Public License for more details.
12 You should have received a copy of the GNU General Public License
13 along with this program; if not, write to the Free Software
14 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
16 #ifndef __REQUEST_TRACKER_HPP
17 #define __REQUEST_TRACKER_HPP
19 #include "SafeCounter.hpp"
21 class RequestTracker {
22 public:
23 RequestTracker(){ init(); }
25 void init() { m_confs.clear(); m_nRefs = 0; }
27 template<typename SignalClass>
28 bool init(SafeCounterManager& mgr,
29 NodeReceiverGroup rg, Uint16 GSN, Uint32 senderData)
31 init();
32 SafeCounter tmp(mgr, m_sc);
33 return tmp.init<SignalClass>(rg, GSN, senderData);
36 bool ignoreRef(SafeCounterManager& mgr, Uint32 nodeId)
37 { return m_sc.clearWaitingFor(mgr, nodeId); }
39 bool reportRef(SafeCounterManager& mgr, Uint32 nodeId)
40 { m_nRefs++; return m_sc.clearWaitingFor(mgr, nodeId); }
42 bool reportConf(SafeCounterManager& mgr, Uint32 nodeId)
43 { m_confs.set(nodeId); return m_sc.clearWaitingFor(mgr, nodeId); }
45 bool hasRef() { return m_nRefs != 0; }
47 bool hasConf() { return !m_confs.isclear(); }
49 bool done() { return m_sc.done(); }
51 private:
52 SafeCounterHandle m_sc;
53 NodeBitmask m_confs;
54 Uint8 m_nRefs;
57 #endif // __REQUEST_TRACKER_HPP