Update some comments

This commit is contained in:
mkrzewic 2018-10-18 13:35:05 +02:00 committed by Dennis Klein
parent d40bbfe208
commit 1f42f49ae5
2 changed files with 19 additions and 15 deletions

View File

@ -62,8 +62,8 @@ FairMQMessagePtr getMessage(ContainerT &&container_, FairMQMemoryResource *targe
}; };
//_________________________________________________________________________________________________ //_________________________________________________________________________________________________
/// Return a vector of const ElemT, resource must be kept alive throughout the /// Return a vector of const ElemT, no wonership transfer.
/// lifetime of the /// Resource must be kept alive throughout the lifetime of the
/// container and associated message. /// container and associated message.
template<typename ElemT> template<typename ElemT>
std::vector<const ElemT, boost::container::pmr::polymorphic_allocator<const ElemT>> adoptVector( std::vector<const ElemT, boost::container::pmr::polymorphic_allocator<const ElemT>> adoptVector(

View File

@ -110,10 +110,9 @@ class ChannelResource : public FairMQMemoryResource
}; };
/// This memory resource only watches, does not allocate/deallocate anything. /// This memory resource only watches, does not allocate/deallocate anything.
/// In combination with the ByteSpectatorAllocator this is an alternative to /// Must be kept alive together with the message as only a pointer to the message is taken.
/// using span, as raw /// In combination with SpectatorAllocator it allows an stl container to "adopt"
/// memory (e.g. an existing buffer message) will be accessible with appropriate /// the contents of the message buffer as it's own.
/// container.
class SpectatorMessageResource : public FairMQMemoryResource class SpectatorMessageResource : public FairMQMemoryResource
{ {
public: public:
@ -167,10 +166,8 @@ class SpectatorMessageResource : public FairMQMemoryResource
/// This memory resource only watches, does not allocate/deallocate anything. /// This memory resource only watches, does not allocate/deallocate anything.
/// Ownership of the message is taken. Meant to be used for transparent data /// Ownership of the message is taken. Meant to be used for transparent data
/// adoption in containers. /// adoption in containers.
/// In combination with the SpectatorAllocator this is an alternative to using /// In combination with SpectatorAllocator it allows an stl container to "adopt"
/// span, as raw memory /// the contents of the message buffer as it's own.
/// (e.g. an existing buffer message) will be accessible with appropriate
/// container.
class MessageResource : public FairMQMemoryResource class MessageResource : public FairMQMemoryResource
{ {
public: public:
@ -218,11 +215,15 @@ class MessageResource : public FairMQMemoryResource
} }
}; };
// This in general (as in STL) is a bad idea, but here it is safe to inherit /// Special allocator that skips default construction/destruction,
// from an allocator since /// allows an stl container to adopt the contents of a buffer as it's own.
// we have no additional data and only override some methods so we don't get /// No ownership of the message or data is taken.
// into slicing and other ///
// problems. /// This in general (as in STL) is a bad idea, but here it is safe to inherit
/// from an allocator since
/// we have no additional data and only override some methods so we don't get
/// into slicing and other
/// problems.
template<typename T> template<typename T>
class SpectatorAllocator : public boost::container::pmr::polymorphic_allocator<T> class SpectatorAllocator : public boost::container::pmr::polymorphic_allocator<T>
{ {
@ -259,6 +260,9 @@ class SpectatorAllocator : public boost::container::pmr::polymorphic_allocator<T
} }
}; };
/// Special allocator that skips default construction/destruction,
/// allows an stl container to adopt the contents of a buffer as it's own.
/// Ownership of the message is taken.
/// This allocator has a pmr-like interface, but keeps the unique /// This allocator has a pmr-like interface, but keeps the unique
/// MessageResource as internal state, /// MessageResource as internal state,
/// allowing full resource (associated message) management internally without /// allowing full resource (associated message) management internally without