|
Hybrid ICN (hICN) plugin
v21.06-rc0-4-g18fa668
|
#include <socket_consumer.h>

Public Member Functions | |
| virtual bool | isBufferMovable () noexcept |
| virtual void | getReadBuffer (uint8_t **application_buffer, size_t *max_length)=0 |
| virtual void | readDataAvailable (size_t length) noexcept=0 |
| virtual size_t | maxBufferSize () const |
| virtual void | readBufferAvailable (std::unique_ptr< utils::MemBuf > &&buffer) noexcept |
| virtual void | readError (const std::error_code ec) noexcept=0 |
| virtual void | readSuccess (std::size_t total_size) noexcept=0 |
The ReadCallback is a class which can be used by the transport for both querying the application needs and notifying events.
Beware that the methods of this class will be called synchronously while the transport is working, so the operations the application is performing on the data retrieved should be executed in another thread in an asynchronous manner. Blocking one of these callbacks means blocking the transport.
|
pure virtual |
This method will be called by the transport when the content is available. The application can then allocate its own buffer and provide the address to the transport, which will use it for writing the data. Note that if the application won't allocate enough memory this method will be called several times, until the internal read buffer will be emptied. For ensuring this method will be called once, applications should allocate at least maxBufferSize() bytes.
| application_buffer | - Pointer to the application's buffer. |
| max_length | - The length of the application buffer. |
|
inlinevirtualnoexcept |
This API will specify to the transport whether the buffer should be allocated by the application (and then the retrieved content will be copied there) or the transport should allocate the buffer and "move" it to the application. In other words, if isBufferMovable return true, the transport will transfer the ownership of the read buffer to the application, without performing an additional copy, while if it returns false the transport will use the getReadBuffer API.
By default this method returns true.
|
inlinevirtual |
This method will be called by the transport for understanding how many bytes it should read before notifying the application.
By default it reads 64 KB.
|
inlinevirtualnoexcept |
This method will be called by the transport iff (isBufferMovable == true). The unique_ptr underlines the fact that the ownership of the buffer is being transferred to the application.
| buffer | - The buffer |
|
pure virtualnoexcept |
This method will be called by the transport after calling getReadBuffer, in order to notify the application that length bytes are available in the buffer. The max_length size of the buffer could be larger than the actual amount of bytes written.
| length | - The number of bytes placed in the buffer. |
|
pure virtualnoexcept |
readError() will be invoked if an error occurs reading from the transport.
| ec | - An error code describing the error. |
|
pure virtualnoexcept |
This callback will be invoked when the whole content is retrieved. The transport itself knows when a content is retrieved (since it is not an opaque bytestream like TCP), and the transport itself is able to tell the application when the transfer is done.
1.8.17