1
/* Copyright (C) 2003 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
16
#ifndef SIGNAL_COUNTER_HPP
17
#define SIGNAL_COUNTER_HPP
19
#include <NodeBitmask.hpp>
20
#include <ErrorReporter.hpp>
23
friend struct NodeReceiverGroup;
27
NdbNodeBitmask m_nodes;
30
SignalCounter() { clearWaitingFor();}
31
void clearWaitingFor();
34
* When sending to different node
36
void setWaitingFor(Uint32 nodeId);
37
void clearWaitingFor(Uint32 nodeId);
38
void forceClearWaitingFor(Uint32 nodeId);
40
bool isWaitingFor(Uint32 nodeId) const;
43
const char * getText() const;
45
SignalCounter& operator=(const NdbNodeBitmask & bitmask);
46
SignalCounter& operator=(const NodeReceiverGroup& rg) {
47
return (* this) = rg.m_nodes;
51
* When sending to same node
53
SignalCounter& operator=(Uint32 count);
54
SignalCounter& operator--(int);
55
SignalCounter& operator++(int);
56
SignalCounter& operator+=(Uint32);
57
Uint32 getCount() const;
62
SignalCounter::setWaitingFor(Uint32 nodeId) {
63
if(!m_nodes.get(nodeId)){
68
ErrorReporter::handleAssert("SignalCounter::set", __FILE__, __LINE__);
73
SignalCounter::isWaitingFor(Uint32 nodeId) const {
74
return m_nodes.get(nodeId);
79
SignalCounter::done() const {
85
SignalCounter::getCount() const {
91
SignalCounter::clearWaitingFor(Uint32 nodeId) {
92
if(m_nodes.get(nodeId) && m_count > 0){
94
m_nodes.clear(nodeId);
97
ErrorReporter::handleAssert("SignalCounter::clear", __FILE__, __LINE__);
102
SignalCounter::clearWaitingFor(){
109
SignalCounter::forceClearWaitingFor(Uint32 nodeId){
110
if(isWaitingFor(nodeId)){
111
clearWaitingFor(nodeId);
117
SignalCounter::operator=(Uint32 count){
125
SignalCounter::operator--(int){
130
ErrorReporter::handleAssert("SignalCounter::operator--", __FILE__, __LINE__);
136
SignalCounter::operator++(int){
143
SignalCounter::operator+=(Uint32 n){
150
SignalCounter::getText() const {
151
static char buf[255];
152
static char nodes[NodeBitmask::TextLength+1];
153
BaseString::snprintf(buf, sizeof(buf), "[SignalCounter: m_count=%d %s]", m_count, m_nodes.getText(nodes));
159
SignalCounter::operator=(const NdbNodeBitmask & bitmask){
161
m_count = bitmask.count();