support stack-allocated IOBufs
Summary:
Previously, all IOBuf APIs required that IOBufs always be allocated on
the heap. The only methods provided to create IOBufs returned
unique_ptr<IOBuf>.
This adds new methods to support creating IOBufs on the stack. This is
useful in cases where the IOBuf will be short-lived, and the overhead of
the heap allocation is undesirable. (One use case is to wrap an
existing buffer in a short-lived IOBuf so that it can be used with the
Cursor API.)
I have currently made IOBufs movable but not copyable. (Move operations
clearly should move only a single IOBuf, but it is not clear if the copy
operators should copy only a single IOBuf or the entire chain.)
Test Plan:
Updated the unit tests to test the new CREATE, WRAP_BUFFER,
TAKE_OWNERSHIP, and COPY_BUFFER constructors, as well as the move
constructor and assignment operator.
Reviewed By: davejwatson@fb.com
FB internal diff:
D1067341