#include <assert.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <uv.h>
#include "nvim/event/loop.h"
#include "nvim/event/wstream.h"
#include "nvim/log.h"
#include "nvim/memory.h"
#include "nvim/vim.h"
Data Structures | |
struct | WRequest |
Macros | |
#define | DEFAULT_MAXMEM 1024 * 1024 * 2000 |
Functions | |
void | wstream_init_fd (Loop *loop, Stream *stream, int fd, size_t maxmem) FUNC_ATTR_NONNULL_ARG(1) FUNC_ATTR_NONNULL_ARG(2) |
void | wstream_init_stream (Stream *stream, uv_stream_t *uvstream, size_t maxmem) FUNC_ATTR_NONNULL_ARG(1) FUNC_ATTR_NONNULL_ARG(2) |
void | wstream_init (Stream *stream, size_t maxmem) |
void | wstream_set_write_cb (Stream *stream, stream_write_cb cb, void *data) FUNC_ATTR_NONNULL_ARG(1 |
bool | wstream_write (Stream *stream, WBuffer *buffer) FUNC_ATTR_NONNULL_ALL |
WBuffer * | wstream_new_buffer (char *data, size_t size, size_t refcount, wbuffer_data_finalizer cb) FUNC_ATTR_NONNULL_ARG(1) |
void | wstream_release_wbuffer (WBuffer *buffer) FUNC_ATTR_NONNULL_ALL |
Variables | |
void stream | cb_data = data |
#define DEFAULT_MAXMEM 1024 * 1024 * 2000 |
WBuffer* wstream_new_buffer | ( | char * | data, |
size_t | size, | ||
size_t | refcount, | ||
wbuffer_data_finalizer | cb | ||
) |
Creates a WBuffer object for holding output data. Instances of this object can be reused across Stream instances, and the memory is freed automatically when no longer needed(it tracks the number of references internally)
data | Data stored by the WBuffer |
size | The size of the data array |
refcount | The number of references for the WBuffer. This will be used by Stream instances to decide when a WBuffer should be freed. |
cb | Pointer to function that will be responsible for freeing the buffer data(passing 'free' will work as expected). |
void wstream_set_write_cb | ( | Stream * | stream, |
stream_write_cb | cb, | ||
void * | data | ||
) |
Sets a callback that will be called on completion of a write request, indicating failure/success.
This affects all requests currently in-flight as well. Overwrites any possible earlier callback.
wstream_write() returns an error
).stream | The Stream instance |
cb | The callback |
Queues data for writing to the backing file descriptor of a Stream
instance. This will fail if the write would cause the Stream use more memory than specified by maxmem
.
stream | The Stream instance |
buffer | The buffer which contains data to be written |