+public:
+ /**
+ An RAII handle for asynchronously writing data into a buffer.
+ */
+ class AsyncTransfer: public NonCopyable
+ {
+ friend BufferBackend;
+ friend class Buffer;
+
+ private:
+ Buffer *buffer = 0;
+ std::size_t offset = 0;
+ std::size_t size = 0;
+ void *dest_addr = 0;
+
+ AsyncTransfer(Buffer &, std::size_t, std::size_t);
+ public:
+ AsyncTransfer() = default;
+ AsyncTransfer(AsyncTransfer &&);
+ AsyncTransfer &operator=(AsyncTransfer &&);
+ ~AsyncTransfer();
+
+ private:
+ void allocate();
+ void finalize();
+
+ public:
+ /** Returns an address for writing the data. It should not be used
+ beyond the lifetime of the object. */
+ void *get_address() { return dest_addr; }
+ };
+