Feature #3100
closed
Add Block constructor to create sub-blocks reusing the underlying buffer
Added by Alex Afanasyev over 9 years ago.
Updated over 9 years ago.
Description
To avoid multiple copy operations during processing of NDNLP packets, a Block should allow creation of sub-blocks reusing the underlying buffer.
/** @brief Create a Block from existing block (reusing the underlying buffer), directly
* specifying boundaries of the block within the buffer
*
* This overload will automatically detect type and position of the value within the block
*/
Block(const Block& block,
const Buffer::const_iterator& begin, const Buffer::const_iterator& end,
bool verifyLength = true);
Does this in any way contradict with the copy-on-write semantics of Block
?
For example:
- create block1 with a full Interest
- create block2 that shares the buffer of block1, covering the Name portion of that Interest
- modify either block1 or block2 using
parse
then insert|delete
then encode
- call
parse
on the other block
Expected: the other block remain unchanged
It does not conflict.
In fact, the same operation is used as part of internal "Block::parse()" method (not exactly the same way, but almost the same). This feature is merely allowing external usage of the function, with creation of blocks from arbitrary offsets inside the underlying wire buffer.
It does not conflict.
To prove this point, test case(s) similar to note-1 steps should be created as part of this issue, in the same commit.
- Status changed from Code review to Closed
- Start date deleted (
08/12/2015)
Also available in: Atom
PDF