/** Class that manages dynamic buffers. It uses a UT_LIST of mtr_buf_t::block_tinstances.Wedon'tuseSTLcontainersin ordertoavoidtheoverheadofheapcalls.Usingacustommemory allocatordoesn'tsolvetheproblemeitherbecausewehavetoget thememoryfromsomewhere.Wecan'tusetheblock_t::m_dataasthe backendforthecustomallocatorbecausewewouldlikethedatain
the blocks to be contiguous. */ class mtr_buf_t { public: /** SIZE - sizeof(m_node) + sizeof(m_used) */ enum { MAX_DATA_SIZE = DYN_ARRAY_DATA_SIZE
- sizeof(ilist_node<>) + sizeof(uint32_t) };
/** Getsthenumberofusedbytesinablock.
@return number of bytes used */
uint32_t used() const { return m_used; }
/** Getspointertothestartofdata.
@return pointer to data */
byte* start()
MY_ATTRIBUTE((warn_unused_result))
{ return(m_data);
}
/**
@return start of data - non const version */
byte* begin()
MY_ATTRIBUTE((warn_unused_result))
{ return(m_data);
}
/**
@return end of used data - non const version */
byte* end()
MY_ATTRIBUTE((warn_unused_result))
{ return(begin() + m_used);
}
/**
@return start of data - const version */ const byte* begin() const
MY_ATTRIBUTE((warn_unused_result))
{ return(m_data);
}
/**
@return end of used data - const version */ const byte* end() const
MY_ATTRIBUTE((warn_unused_result))
{ return(begin() + m_used);
}
private: /**
@return pointer to start of reserved space */ template <typename Type>
Type push(uint32_t size)
{
Type ptr = reinterpret_cast<Type>(end());
/**
Initialise the block */ void init()
{
m_used = 0;
ut_d(m_buf_end = 0);
ut_d(m_magic_n = DYN_BLOCK_MAGIC_N);
} private: #ifdef UNIV_DEBUG /** If opened then this is the buffer end offset, else 0 */
ulint m_buf_end;
/** Magic number (DYN_BLOCK_MAGIC_N) */
ulint m_magic_n; #endif/* UNIV_DEBUG */
/** Storage */
byte m_data[MAX_DATA_SIZE];
/** number of data bytes used in this block */
uint32_t m_used;
/** Reset the buffer vector */ void erase()
{ if (m_heap != NULL) {
mem_heap_free(m_heap);
m_heap = NULL;
/* Initialise the list and add the first block. */
m_list.clear();
m_list.push_back(m_first_block);
} else {
ut_ad(front() == &m_first_block);
ut_ad(back() == &m_first_block);
m_first_block.init();
}
}
private: /** Heap to use for memory allocation */
mem_heap_t* m_heap;
/** Allocated blocks */
list_t m_list;
/** The default block, should always be the first element. This isforbackwardscompatibilityandtoavoidanextraheapallocation
for small REDO log records */
block_t m_first_block;
};
#endif/* dyn0buf_h */
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.11 Sekunden
(vorverarbeitet am 2026-10-08)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.