Skip to content

[DPL] Support for resizable DataChunk#1873

Merged
matthiasrichter merged 2 commits intoAliceO2Group:devfrom
matthiasrichter:dev-framework-data-allocator
Apr 16, 2019
Merged

[DPL] Support for resizable DataChunk#1873
matthiasrichter merged 2 commits intoAliceO2Group:devfrom
matthiasrichter:dev-framework-data-allocator

Conversation

@matthiasrichter
Copy link
Copy Markdown
Collaborator

Details to be found in #1846

Change DataChunk to be of type std::vector<char, o2::pmr::polymorphic_allocator>

Interface changes:
- makeChunk returns reference to std::vector<char> object with polymorphic_allocator
- return value of adoptChunk is dropped, not possible to preserve this, not been used
  anyhow

This goes in line with the general idea of DataAllocator's `make` methods, where the
object is booked with one single call and is send automatically after processing ends.
Requires return by reference and to use a reference variable in the code. The disadvantage
is that accidental copy is possible and impossible to detect at compile time.

Details:
Introducing VectorObject to MessageContext, holding an instance of a vector.
The memory is directly allocated in the message memory using the pmr functionality.
In order to avoid that objects go out of scope and the allocated buffer is available
at send, the created vector can not be returned by move, but is kept in the context
and returned by reference. This requires changes in the code to use the reference
instead of a copy.

The return value of adoptChunk must be dropped because a buffer can only be adopted
to a vector object using a special allocator. With this it can not simply be returned
as it is a different type. Using polymorphic_allocator even for trivially default
constructible types still invokes the constructor for the elements, thus changing
the memory of the underlying resource.
Make DataChunk a class deriving from std::vector instead of an alias. This allows
to delete the copy constructor and assignment operator.

DPL's output allocator returns the created DataChunk by reference and thus it's important
not to make a copy in the code. Now it's ensured to detect this at compile time.
@matthiasrichter matthiasrichter merged commit 55d1a32 into AliceO2Group:dev Apr 16, 2019
@matthiasrichter matthiasrichter deleted the dev-framework-data-allocator branch April 16, 2019 09:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant