You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@qpid.apache.org by Alan Conway <ac...@redhat.com> on 2008/09/24 22:07:07 UTC

C++ client/broker: avoiding unread

Just FYI: In the cluster code I needed to decode from data buffers that
might not coincide with frame boundaries, but without having anything
like the AsyncIOs "unread" feature.

qpid/framing/FrameDecoder.h is a simple and I believe efficient solution
to this problem. It provides a buffer (growable but never larger than
the largest frame decoded) to save a frame fragment found at the end of
a read buffer. The rest of the frame is copied from the front of the
next read buffer when it arrives. Only fragmented frames are ever
copied, at most one per read buffer.

The buffer does get reallocated but the number of allocations will be
small.

Cheers,
Alan.