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
{
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
)
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(); }
52 SafeCounterHandle m_sc
;
57 #endif // __REQUEST_TRACKER_HPP