[DPL] Support for resizable DataChunk#1873
Merged
matthiasrichter merged 2 commits intoAliceO2Group:devfrom Apr 16, 2019
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Details to be found in #1846