MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
VMSignal.hpp
1 /*
2  Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
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 as published by
6  the Free Software Foundation; version 2 of the License.
7 
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  GNU General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License
14  along with this program; if not, write to the Free Software
15  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
16 */
17 
18 #ifndef VMSignal_H
19 #define VMSignal_H
20 
21 #include <ndb_global.h>
22 #include <ndb_limits.h>
23 #include <kernel_types.h>
24 
25 #include <ErrorReporter.hpp>
26 #include <NodeBitmask.hpp>
27 
28 #include <RefConvert.hpp>
29 #include <TransporterDefinitions.hpp>
30 
31 extern void getSections(Uint32 secCount, SegmentedSectionPtr ptr[3]);
32 
34 {
36  SectionHandle (class SimulatedBlock*, Uint32 ptrI);
37  SectionHandle (class SimulatedBlock*, class Signal*);
38  ~SectionHandle ();
39 
40  Uint32 m_cnt;
41  SegmentedSectionPtr m_ptr[3];
42 
43  bool getSection(SegmentedSectionPtr & ptr, Uint32 sectionNo);
44  void clear() { m_cnt = 0;}
45 
46  SimulatedBlock* m_block;
47 };
48 
54  NodeReceiverGroup(Uint32 blockRef);
55  NodeReceiverGroup(Uint32 blockNo, const NodeBitmask &);
56  NodeReceiverGroup(Uint32 blockNo, const NdbNodeBitmask &);
57  NodeReceiverGroup(Uint32 blockNo, const class SignalCounter &);
58 
59  NodeReceiverGroup& operator=(BlockReference ref);
60 
61  Uint32 m_block;
62  NodeBitmask m_nodes;
63 };
64 
65 template <unsigned T> struct SignalT
66 {
67  Uint32 m_sectionPtrI[3];
68  SignalHeader header;
69  union {
70  Uint32 theData[T];
71  Uint64 dummyAlign;
72  };
73 };
74 
78 class Signal {
79  friend class SimulatedBlock;
80  friend class APZJobBuffer;
81  friend class FastScheduler;
82 public:
83  Signal(int); // for placement new
84  Signal();
85 
86  Uint32 getLength() const;
87  Uint32 getTrace() const;
88  Uint32 getSendersBlockRef() const;
89 
90  const Uint32* getDataPtr() const ;
91  Uint32* getDataPtrSend() ;
92 
93  void setTrace(Uint32);
94 
95  Uint32 getNoOfSections() const;
96 
100  Uint32 length() const { return getLength();}
101  BlockReference senderBlockRef() const { return getSendersBlockRef();}
102 
103 private:
104  void setLength(Uint32);
105 
106 public:
107 #define VMS_DATA_SIZE \
108  (MAX_ATTRIBUTES_IN_TABLE + MAX_TUPLE_SIZE_IN_WORDS + MAX_KEY_SIZE_IN_WORDS)
109 
110 #if VMS_DATA_SIZE > 8192
111 #error "VMSignal buffer is too small"
112 #endif
113 
114  Uint32 m_sectionPtrI[3];
115  SignalHeader header; // 28 bytes
116  union {
117  Uint32 theData[8192]; // 8192 32-bit words -> 32K Bytes
118  Uint64 dummyAlign;
119  };
120  void garbage_register();
121 };
122 
123 template<Uint32 len>
125 {
126  Uint32 m_copy[len];
127  Signal * m_signal;
128 
129 public:
130  SaveSignal(Signal* signal) {
131  save(signal);
132  }
133 
134  void save(Signal* signal) {
135  m_signal = signal;
136  for (Uint32 i = 0; i<len; i++)
137  m_copy[i] = m_signal->theData[i];
138  }
139 
140  void clear() { m_signal = 0;}
141 
142  void restore() {
143  for (Uint32 i = 0; i<len; i++)
144  m_signal->theData[i] = m_copy[i];
145  }
146 
147  ~SaveSignal() {
148  if (m_signal)
149  restore();
150  clear();
151  }
152 };
153 
154 inline
155 Uint32
156 Signal::getLength() const {
157  return header.theLength;
158 }
159 
160 inline
161 Uint32
162 Signal::getTrace() const {
163  return header.theTrace;
164 }
165 
166 inline
167 Uint32
168 Signal::getSendersBlockRef() const {
169  return header.theSendersBlockRef;
170 }
171 
172 inline
173 const Uint32*
174 Signal::getDataPtr() const {
175  return &theData[0];
176 }
177 
178 inline
179 Uint32*
180 Signal::getDataPtrSend() {
181  return &theData[0];
182 }
183 
184 inline
185 void
186 Signal::setLength(Uint32 len){
187  header.theLength = len;
188 }
189 
190 inline
191 void
192 Signal::setTrace(Uint32 t){
193  header.theTrace = t;
194 }
195 
196 inline
197 Uint32
198 Signal::getNoOfSections() const {
199  return header.m_noOfSections;
200 }
201 
202 inline
203 NodeReceiverGroup::NodeReceiverGroup() : m_block(0){
204  m_nodes.clear();
205 }
206 
207 inline
208 NodeReceiverGroup::NodeReceiverGroup(Uint32 blockRef){
209  m_nodes.clear();
210  m_block = refToBlock(blockRef);
211  m_nodes.set(refToNode(blockRef));
212 }
213 
214 inline
215 NodeReceiverGroup::NodeReceiverGroup(Uint32 blockNo,
216  const NodeBitmask & nodes)
217 {
218  m_block = blockNo;
219  m_nodes = nodes;
220 }
221 
222 inline
223 NodeReceiverGroup::NodeReceiverGroup(Uint32 blockNo,
224  const NdbNodeBitmask & nodes)
225 {
226  m_block = blockNo;
227  m_nodes = nodes;
228 }
229 
230 #include "SignalCounter.hpp"
231 
232 inline
233 NodeReceiverGroup::NodeReceiverGroup(Uint32 blockNo,
234  const SignalCounter & nodes){
235  m_block = blockNo;
236  m_nodes = nodes.m_nodes;
237 }
238 
239 inline
241 NodeReceiverGroup::operator=(BlockReference blockRef){
242  m_nodes.clear();
243  m_block = refToBlock(blockRef);
244  m_nodes.set(refToNode(blockRef));
245  return * this;
246 }
247 
248 inline
249 SectionHandle::SectionHandle(SimulatedBlock* b)
250  : m_cnt(0),
251  m_block(b)
252 {
253 }
254 
255 inline
256 SectionHandle::SectionHandle(SimulatedBlock* b, Signal* s)
257  : m_cnt(s->header.m_noOfSections),
258  m_block(b)
259 {
260  Uint32 * ptr = s->m_sectionPtrI;
261  Uint32 ptr0 = * ptr++;
262  Uint32 ptr1 = * ptr++;
263  Uint32 ptr2 = * ptr++;
264 
265  m_ptr[0].i = ptr0;
266  m_ptr[1].i = ptr1;
267  m_ptr[2].i = ptr2;
268 
269  getSections(m_cnt, m_ptr);
270 
271  s->header.m_noOfSections = 0;
272 }
273 
274 inline
275 SectionHandle::SectionHandle(SimulatedBlock* b, Uint32 ptr)
276  : m_cnt(1),
277  m_block(b)
278 {
279  m_ptr[0].i = ptr;
280  getSections(1, m_ptr);
281 }
282 
283 inline
284 bool
285 SectionHandle::getSection(SegmentedSectionPtr& ptr, Uint32 no)
286 {
287  if (likely(no < m_cnt))
288  {
289  ptr = m_ptr[no];
290  return true;
291  }
292 
293  return false;
294 }
295 
296 #endif