~vadim-tk/percona-server/percona-5.5.15-galera

« back to all changes in this revision

Viewing changes to storage/ndb/src/kernel/vm/VMSignal.hpp

  • Committer: root
  • Date: 2011-09-10 16:37:18 UTC
  • Revision ID: root@r815.office.percona.com-20110910163718-ydh4zj8hcdgoyavb
Porting Galera to 5.5.15

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (C) 2003 MySQL AB
 
2
 
 
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.
 
6
 
 
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.
 
11
 
 
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 */
 
15
 
 
16
#ifndef VMSignal_H
 
17
#define VMSignal_H
 
18
 
 
19
#include <ndb_global.h>
 
20
#include <ndb_limits.h>
 
21
#include <kernel_types.h>
 
22
 
 
23
#include <ErrorReporter.hpp>
 
24
#include <NodeBitmask.hpp>
 
25
 
 
26
#include <RefConvert.hpp>
 
27
#include <TransporterDefinitions.hpp>
 
28
 
 
29
/**
 
30
 * Struct used when sending to multiple blocks
 
31
 */
 
32
struct NodeReceiverGroup {
 
33
  NodeReceiverGroup();
 
34
  NodeReceiverGroup(Uint32 blockRef);
 
35
  NodeReceiverGroup(Uint32 blockNo, const NodeBitmask &);
 
36
  NodeReceiverGroup(Uint32 blockNo, const class SignalCounter &);
 
37
  
 
38
  NodeReceiverGroup& operator=(BlockReference ref);
 
39
  
 
40
  Uint32 m_block;
 
41
  NodeBitmask m_nodes;
 
42
};
 
43
 
 
44
template <unsigned T> struct SignalT
 
45
{
 
46
  SignalHeader header;
 
47
  SegmentedSectionPtr m_sectionPtr[3]; 
 
48
  union {
 
49
    Uint32 theData[T];
 
50
    Uint64 dummyAlign;
 
51
  };
 
52
};
 
53
 
 
54
/**
 
55
 * class used for passing argumentes to blocks
 
56
 */
 
57
class Signal {
 
58
  friend class SimulatedBlock;
 
59
  friend class APZJobBuffer;
 
60
  friend class FastScheduler;
 
61
public:
 
62
  Signal();
 
63
  
 
64
  Uint32 getLength() const;
 
65
  Uint32 getTrace() const;
 
66
  Uint32 getSendersBlockRef() const;
 
67
 
 
68
  const Uint32* getDataPtr() const ;
 
69
  Uint32* getDataPtrSend() ;
 
70
  
 
71
  void setTrace(Uint32);
 
72
 
 
73
  Uint32 getNoOfSections() const;
 
74
  bool getSection(SegmentedSectionPtr & ptr, Uint32 sectionNo);
 
75
  void setSection(SegmentedSectionPtr ptr, Uint32 sectionNo);
 
76
 
 
77
  /**
 
78
   * Old depricated methods...
 
79
   */
 
80
  Uint32 length() const { return getLength();}
 
81
  BlockReference senderBlockRef() const { return getSendersBlockRef();}
 
82
 
 
83
private:
 
84
  void setLength(Uint32);
 
85
  
 
86
public:
 
87
#define VMS_DATA_SIZE \
 
88
  (MAX_ATTRIBUTES_IN_TABLE + MAX_TUPLE_SIZE_IN_WORDS + MAX_KEY_SIZE_IN_WORDS)
 
89
 
 
90
#if VMS_DATA_SIZE > 8192
 
91
#error "VMSignal buffer is too small"
 
92
#endif
 
93
  
 
94
  SignalHeader header; // 28 bytes
 
95
  SegmentedSectionPtr m_sectionPtr[3]; 
 
96
  union {
 
97
    Uint32 theData[8192];  // 8192 32-bit words -> 32K Bytes
 
98
    Uint64 dummyAlign;
 
99
  };
 
100
  void garbage_register();
 
101
};
 
102
 
 
103
inline
 
104
Uint32
 
105
Signal::getLength() const {
 
106
  return header.theLength;
 
107
}
 
108
 
 
109
inline
 
110
Uint32
 
111
Signal::getTrace() const {
 
112
  return header.theTrace;
 
113
}
 
114
 
 
115
inline
 
116
Uint32
 
117
Signal::getSendersBlockRef() const {
 
118
  return header.theSendersBlockRef;
 
119
}
 
120
 
 
121
inline
 
122
const Uint32* 
 
123
Signal::getDataPtr() const { 
 
124
  return &theData[0];
 
125
}
 
126
 
 
127
inline
 
128
Uint32* 
 
129
Signal::getDataPtrSend() { 
 
130
  return &theData[0];
 
131
}
 
132
 
 
133
inline
 
134
void
 
135
Signal::setLength(Uint32 len){
 
136
  header.theLength = len;
 
137
}
 
138
 
 
139
inline
 
140
void
 
141
Signal::setTrace(Uint32 t){
 
142
  header.theTrace = t;
 
143
}
 
144
 
 
145
inline
 
146
Uint32 
 
147
Signal::getNoOfSections() const {
 
148
  return header.m_noOfSections;
 
149
}
 
150
 
 
151
inline
 
152
bool 
 
153
Signal::getSection(SegmentedSectionPtr & ptr, Uint32 section){
 
154
  if(section < header.m_noOfSections){
 
155
    ptr = m_sectionPtr[section];
 
156
    return true;
 
157
  }
 
158
  ptr.p = 0;
 
159
  return false;
 
160
}
 
161
 
 
162
inline
 
163
void
 
164
Signal::setSection(SegmentedSectionPtr ptr, Uint32 sectionNo){
 
165
  if(sectionNo != header.m_noOfSections || sectionNo > 2){
 
166
    abort();
 
167
  }
 
168
  m_sectionPtr[sectionNo] = ptr;
 
169
  header.m_noOfSections++;
 
170
}
 
171
 
 
172
inline
 
173
NodeReceiverGroup::NodeReceiverGroup() : m_block(0){
 
174
  m_nodes.clear();
 
175
}
 
176
 
 
177
inline
 
178
NodeReceiverGroup::NodeReceiverGroup(Uint32 blockRef){
 
179
  m_nodes.clear();
 
180
  m_block = refToBlock(blockRef);
 
181
  m_nodes.set(refToNode(blockRef));
 
182
}
 
183
 
 
184
inline
 
185
NodeReceiverGroup::NodeReceiverGroup(Uint32 blockNo, const NodeBitmask & nodes){
 
186
  m_block = blockNo;
 
187
  m_nodes = nodes;
 
188
}
 
189
 
 
190
#include "SignalCounter.hpp"
 
191
 
 
192
inline
 
193
NodeReceiverGroup::NodeReceiverGroup(Uint32 blockNo, const SignalCounter & nodes){
 
194
  m_block = blockNo;
 
195
  m_nodes = nodes.m_nodes;
 
196
}
 
197
 
 
198
inline
 
199
NodeReceiverGroup& 
 
200
NodeReceiverGroup::operator=(BlockReference blockRef){
 
201
  m_nodes.clear();
 
202
  m_block = refToBlock(blockRef);
 
203
  m_nodes.set(refToNode(blockRef));
 
204
  return * this;
 
205
}
 
206
 
 
207
#endif