19 #include <SimpleProperties.hpp>
20 #include <TransporterDefinitions.hpp>
21 #include "LongSignal.hpp"
22 #include "LongSignalImpl.hpp"
23 #include "SimulatedBlock.hpp"
25 SimplePropertiesSectionReader::SimplePropertiesSectionReader
38 m_currentSegment = ptr.p;
44 SimplePropertiesSectionReader::reset(){
46 m_currentSegment = m_head;
50 SimplePropertiesSectionReader::step(Uint32 len){
51 if(m_pos + len >= m_len) {
55 while(len > SectionSegment::DataLength){
56 m_currentSegment = m_pool.
getPtr(m_currentSegment->m_nextSegment);
58 len -= SectionSegment::DataLength;
59 m_pos += SectionSegment::DataLength;
62 Uint32 ind = m_pos % SectionSegment::DataLength;
68 if(ind == SectionSegment::DataLength){
70 m_currentSegment = m_pool.
getPtr(m_currentSegment->m_nextSegment);
77 SimplePropertiesSectionReader::getWord(Uint32 * dst){
86 SimplePropertiesSectionReader::peekWord(Uint32 * dst)
const {
88 Uint32 ind = m_pos % SectionSegment::DataLength;
89 * dst = m_currentSegment->theData[ind];
96 SimplePropertiesSectionReader::peekWords(Uint32 * dst, Uint32 len)
const {
97 if(m_pos + len > m_len){
100 Uint32 ind = (m_pos % SectionSegment::DataLength);
101 Uint32 left = (SectionSegment::DataLength - ind);
105 memcpy(dst, &p->theData[ind], 4 * left);
109 left = SectionSegment::DataLength;
110 p = m_pool.
getPtr(p->m_nextSegment);
113 memcpy(dst, &p->theData[ind], 4 * len);
118 SimplePropertiesSectionReader::getWords(Uint32 * dst, Uint32 len){
119 if(peekWords(dst, len)){
127 : m_pool(block.getSectionSegmentPool()), m_block(block)
131 m_currentSegment = 0;
136 SimplePropertiesSectionWriter::~SimplePropertiesSectionWriter()
141 #ifdef NDBD_MULTITHREADED
142 #define SP_POOL_ARG f_section_lock, *m_block.m_sectionPoolCache,
148 SimplePropertiesSectionWriter::release()
156 ptr.i = m_head->m_lastSegment;
159 m_head->m_lastSegment = m_currentSegment->m_lastSegment;
161 if((m_pos % SectionSegment::DataLength) == 0){
162 m_pool.
release(SP_POOL_ARG m_currentSegment->m_lastSegment);
163 m_head->m_lastSegment = m_prevPtrI;
165 m_block.release(ptr);
169 m_pool.
release(SP_POOL_ARG m_head->m_lastSegment);
174 m_currentSegment = 0;
179 SimplePropertiesSectionWriter::reset()
183 if(m_pool.
seize(SP_POOL_ARG first)){
188 m_currentSegment = 0;
195 m_head->m_lastSegment = first.i;
196 m_currentSegment = first.p;
202 SimplePropertiesSectionWriter::putWord(Uint32 val){
203 return putWords(&val, 1);
207 SimplePropertiesSectionWriter::putWords(
const Uint32 * src, Uint32 len){
208 Uint32 left = SectionSegment::DataLength - m_pos;
211 memcpy(&m_currentSegment->theData[m_pos], src, 4 * left);
213 if(m_pool.
seize(SP_POOL_ARG next)){
215 m_prevPtrI = m_currentSegment->m_lastSegment;
216 m_currentSegment->m_nextSegment = next.i;
217 next.p->m_lastSegment = next.i;
218 m_currentSegment = next.p;
224 left = SectionSegment::DataLength;
232 memcpy(&m_currentSegment->theData[m_pos], src, 4 * len);
236 assert(m_pos < (
int)SectionSegment::DataLength);
241 Uint32 SimplePropertiesSectionWriter::getWordsUsed()
const
251 dst.i = m_head->m_lastSegment;
254 m_head->m_lastSegment = m_currentSegment->m_lastSegment;
256 if((m_pos % SectionSegment::DataLength) == 0){
257 m_pool.
release(SP_POOL_ARG m_currentSegment->m_lastSegment);
258 m_head->m_lastSegment = m_prevPtrI;
263 m_head = m_currentSegment = 0;
273 m_pool.
release(SP_POOL_ARG m_head->m_lastSegment);
278 m_head = m_currentSegment = 0;