~CSmartRowBuffer() { #ifdef _FULL_TRACE ActPrintLog(activity, "SmartBuffer destroy %x",(unsigned)(memsize_t)this); #endif assertex(!waiting); assertex(!waitflush); // clear in/out contents while (in->ordinality()) ReleaseThorRow(in->dequeue()); delete in; while (out->ordinality()) ReleaseThorRow(out->dequeue()); delete out; }
inline void setown(const void * _ptr) { TESTROW(_ptr); const void * temp = ptr; ptr = _ptr; if (temp) ReleaseThorRow(temp); }
inline void set(const void * _ptr) { const void * temp = ptr; if (_ptr) LinkThorRow(_ptr); ptr = _ptr; if (temp) ReleaseThorRow(temp); }
void stop() { #ifdef _FULL_TRACE ActPrintLog(activity, "SmartBuffer stop %x",(unsigned)(memsize_t)this); #endif SpinBlock block(lock); #ifdef _DEBUG if (waiting) { ActPrintLogEx(&activity->queryContainer(), thorlog_null, MCwarning, "CSmartRowBuffer::stop while nextRow waiting"); PrintStackReport(); } #endif eoi = true; while (out&&out->ordinality()) ReleaseThorRow(out->dequeue()); while (NULL == in) { waiting = true; SpinUnblock unblock(lock); waitsem.wait(); } while (out&&out->ordinality()) ReleaseThorRow(out->dequeue()); while (in&&in->ordinality()) ReleaseThorRow(in->dequeue()); diskin.kill(); if (waiting) { waitsem.signal(); waiting = false; } if (waitflush) { waitflushsem.signal(); waitflush = false; } }
void putRow(const void *row) { REENTRANCY_CHECK(putrecheck) size32_t sz = thorRowMemoryFootprint(serializer, row); SpinBlock block(lock); if (eoi) { ReleaseThorRow(row); return; } assertex(in); // reentry check if (sz+insz+(in->ordinality()+2)*sizeof(byte)>blocksize) // byte extra per row + end byte diskflush(); in->enqueue(row); insz += sz; if (waiting) { waitsem.signal(); waiting = false; } }
inline ~OwnedConstThorRow() { ReleaseThorRow(ptr); }
inline void clear() { const void *temp=ptr; ptr=NULL; ReleaseThorRow(temp); }