Skip to content
Snippets Groups Projects
Commit 960d62ca authored by Wainer Vandelli's avatar Wainer Vandelli
Browse files

Dynamically extend the list of unchecked fragments

Implements a dynamic allocation of the list of unchecked fragments. As
such any number of fragments can be supported.
Follow up of ATDSUPPORT-372
parent b573c05f
No related branches found
No related tags found
No related merge requests found
Pipeline #4121154 passed
...@@ -21,12 +21,6 @@ namespace eformat { ...@@ -21,12 +21,6 @@ namespace eformat {
namespace write { namespace write {
/**
* Maximum number of unchecked fragments a writeable FullEventFragment
* may have.
*/
const uint32_t MAX_UNCHECKED_FRAGMENTS = 2048;
/** /**
* Defines a helper class to aid the creation of FullEvent fragments. * Defines a helper class to aid the creation of FullEvent fragments.
*/ */
...@@ -568,7 +562,8 @@ namespace eformat { ...@@ -568,7 +562,8 @@ namespace eformat {
eformat::write::ROBFragment* m_last; ///< my last child eformat::write::ROBFragment* m_last; ///< my last child
uint32_t m_checksum; ///< My payload's checksum, if asked uint32_t m_checksum; ///< My payload's checksum, if asked
uint32_t m_n_unchecked; ///< The number of unchecked nodes attached uint32_t m_n_unchecked; ///< The number of unchecked nodes attached
eformat::write::node_t m_unchecked[MAX_UNCHECKED_FRAGMENTS]; ///< Unchecked nodes uint32_t m_unchecked_size; ///< The size of unchecked node array
eformat::write::node_t * m_unchecked; ///< Unchecked nodes
eformat::write::node_t m_compressed_node; ///< Compressed node eformat::write::node_t m_compressed_node; ///< Compressed node
std::unique_ptr<compression::CompressionBuffer> m_compressed; ///< Compressed event std::unique_ptr<compression::CompressionBuffer> m_compressed; ///< Compressed event
unsigned int m_compression_level; ///< Compression level unsigned int m_compression_level; ///< Compression level
......
...@@ -64,6 +64,10 @@ void eformat::write::FullEventFragment::initialize() ...@@ -64,6 +64,10 @@ void eformat::write::FullEventFragment::initialize()
m_checksum = 0; m_checksum = 0;
set(m_node[11], &m_checksum, 1, 0); set(m_node[11], &m_checksum, 1, 0);
//allocate the initial unchecked array
m_unchecked_size = 2500;
m_unchecked = new eformat::write::node_t[m_unchecked_size];
//our unchecked data //our unchecked data
m_n_unchecked = 0; m_n_unchecked = 0;
set(m_unchecked[0], 0, 0, 0); set(m_unchecked[0], 0, 0, 0);
...@@ -123,6 +127,7 @@ eformat::write::FullEventFragment::FullEventFragment ...@@ -123,6 +127,7 @@ eformat::write::FullEventFragment::FullEventFragment
eformat::write::FullEventFragment::~FullEventFragment() eformat::write::FullEventFragment::~FullEventFragment()
{ {
delete[] m_unchecked;
} }
eformat::write::FullEventFragment& eformat::write::FullEventFragment&
...@@ -272,8 +277,24 @@ void eformat::write::FullEventFragment::append ...@@ -272,8 +277,24 @@ void eformat::write::FullEventFragment::append
void eformat::write::FullEventFragment::append_unchecked (const uint32_t* rob) void eformat::write::FullEventFragment::append_unchecked (const uint32_t* rob)
{ {
if (m_n_unchecked == MAX_UNCHECKED_FRAGMENTS) if (m_n_unchecked == m_unchecked_size){
throw EFORMAT_TOO_MANY_UNCHECKED(MAX_UNCHECKED_FRAGMENTS);
m_unchecked_size *= 2;
auto tmp = new eformat::write::node_t[m_unchecked_size];
// Copy the linked list updating the addresses
for(uint32_t i = 0; i < m_n_unchecked; ++i){
set(tmp[i], m_unchecked[i].base,
m_unchecked[i].size_word, &tmp[i+1]);
}
// Set last address to 0
tmp[m_n_unchecked-1].next = 0;
delete[] m_unchecked;
m_unchecked = tmp;
}
eformat::ROBFragment<const uint32_t*> frag(rob); eformat::ROBFragment<const uint32_t*> frag(rob);
if (m_n_unchecked) //more fragments are available before this one if (m_n_unchecked) //more fragments are available before this one
m_unchecked[m_n_unchecked-1].next = &m_unchecked[m_n_unchecked]; m_unchecked[m_n_unchecked-1].next = &m_unchecked[m_n_unchecked];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment