]> git.meshlink.io Git - meshlink/blobdiff - src/meshlink.h
Add meshlink_channel_aio_send().
[meshlink] / src / meshlink.h
index 40deb5f1a04a111a0bcaf1bc4e3baa4ed5a92e38..5c5196ab7097ae5e91adb6312017d01ece5ab541 100644 (file)
@@ -1125,6 +1125,34 @@ extern void meshlink_channel_close(meshlink_handle_t *mesh, meshlink_channel_t *
  */
 extern ssize_t meshlink_channel_send(meshlink_handle_t *mesh, meshlink_channel_t *channel, const void *data, size_t len);
 
+/// A callback for cleaning up buffers submitted for asynchronous I/O.
+/** This callbacks signals that MeshLink has finished using this buffer.
+ *  The ownership of the buffer is now back into the application's hands.
+ *
+ *  @param mesh      A handle which represents an instance of MeshLink.
+ *  @param channel   A handle for the channel which used this buffer.
+ *  @param data      A pointer to a buffer containing the enqueued data.
+ *  @param len       The length of the buffer.
+ *  @param priv      A private pointer which was set by the application when submitting the buffer.
+};
+ */
+typedef void (*meshlink_aio_cb_t)(meshlink_handle_t *mesh, meshlink_channel_t *channel, const void *data, size_t len, void *priv);
+
+/// Transmit data on a channel asynchronously
+/** This queues data to send to the remote node.
+ *
+ *  @param mesh         A handle which represents an instance of MeshLink.
+ *  @param channel      A handle for the channel.
+ *  @param data         A pointer to a buffer containing data sent by the source, or NULL if there is no data to send.
+ *                      After meshlink_channel_aio_send() returns, the buffer may not be modified or freed by the application
+ *                      until the callback routine is called.
+ *  @param len          The length of the data, or 0 if there is no data to send.
+ *  @param cb           A pointer to the function which will be called when MeshLink has finished using the buffer.
+ *
+ *  @return             True if the buffer was enqueued, false otherwise.
+ */
+extern bool meshlink_channel_aio_send(meshlink_handle_t *mesh, meshlink_channel_t *channel, const void *data, size_t len, meshlink_aio_cb_t cb, void *priv);
+
 /// Get channel flags.
 /** This returns the flags used when opening this channel.
  *