1 /* 2 Copyright (c) 2003, 2021, Oracle and/or its affiliates. 3 4 This program is free software; you can redistribute it and/or modify 5 it under the terms of the GNU General Public License, version 2.0, 6 as published by the Free Software Foundation. 7 8 This program is also distributed with certain software (including 9 but not limited to OpenSSL) that is licensed under separate terms, 10 as designated in a particular file or component or in included license 11 documentation. The authors of MySQL hereby grant you an additional 12 permission to link the program and your derivative works with the 13 separately licensed software that they have included with MySQL. 14 15 This program is distributed in the hope that it will be useful, 16 but WITHOUT ANY WARRANTY; without even the implied warranty of 17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 GNU General Public License, version 2.0, for more details. 19 20 You should have received a copy of the GNU General Public License 21 along with this program; if not, write to the Free Software 22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 23 */ 24 25 #ifndef __REQUEST_TRACKER_HPP 26 #define __REQUEST_TRACKER_HPP 27 28 #include "SafeCounter.hpp" 29 30 #define JAM_FILE_ID 328 31 32 33 class RequestTracker { 34 public: RequestTracker()35 RequestTracker(){ init(); } 36 init()37 void init() { m_confs.clear(); m_nRefs = 0; } 38 39 template<typename SignalClass> init(SafeCounterManager & mgr,NodeReceiverGroup rg,Uint16 GSN,Uint32 senderData)40 bool init(SafeCounterManager& mgr, 41 NodeReceiverGroup rg, Uint16 GSN, Uint32 senderData) 42 { 43 init(); 44 SafeCounter tmp(mgr, m_sc); 45 return tmp.init<SignalClass>(rg, GSN, senderData); 46 } 47 ignoreRef(SafeCounterManager & mgr,Uint32 nodeId)48 bool ignoreRef(SafeCounterManager& mgr, Uint32 nodeId) 49 { return m_sc.clearWaitingFor(mgr, nodeId); } 50 reportRef(SafeCounterManager & mgr,Uint32 nodeId)51 bool reportRef(SafeCounterManager& mgr, Uint32 nodeId) 52 { m_nRefs++; return m_sc.clearWaitingFor(mgr, nodeId); } 53 reportConf(SafeCounterManager & mgr,Uint32 nodeId)54 bool reportConf(SafeCounterManager& mgr, Uint32 nodeId) 55 { m_confs.set(nodeId); return m_sc.clearWaitingFor(mgr, nodeId); } 56 hasRef()57 bool hasRef() { return m_nRefs != 0; } 58 hasConf()59 bool hasConf() { return !m_confs.isclear(); } 60 done()61 bool done() { return m_sc.done(); } 62 63 NdbNodeBitmask m_confs; 64 65 private: 66 SafeCounterHandle m_sc; 67 Uint8 m_nRefs; 68 }; 69 70 71 #undef JAM_FILE_ID 72 73 #endif // __REQUEST_TRACKER_HPP 74