facil.io

#./fio-stl/102 stream.h

16 public symbols.

#Macros

#FIO_STREAM_COPY_PER_PACKET

c
#define FIO_STREAM_COPY_PER_PACKET 98304

Break apart large memory blocks into smaller pieces. by default 96Kb

Symbol type: macro

#FIO_STREAM_ALWAYS_COPY_IF_LESS_THAN

c
#define FIO_STREAM_ALWAYS_COPY_IF_LESS_THAN 116

If the data added is less than said bytes, copy is preferred (locality).

Symbol type: macro

#FIO_STREAM_INIT

c
#define FIO_STREAM_INIT(s)   \
  { .next = NULL, .pos = &(s).next }

Symbol type: macro

#Types

#fio_stream_packet_s

c
struct fio_stream_packet_s

Symbol type: type

#fio_stream_s

c
typedef struct {
/* do not directly access! */
fio_stream_packet_s *next;
fio_stream_packet_s **pos;
size_t consumed;
size_t length;
} fio_stream_s

Symbol type: type

#Functions

#fio_stream_new

c
inline fio_stream_s *fio_stream_new(void)

Symbol type: function

#fio_stream_free

c
inline int fio_stream_free(fio_stream_s *stream)

Symbol type: function

#fio_stream_destroy

c
void fio_stream_destroy(fio_stream_s *stream)

Destroys the object, re-initializing its container.

Symbol type: function

#fio_stream_pack_data

c
fio_stream_packet_s *fio_stream_pack_data(void *buf, size_t len, size_t offset, uint8_t copy_buffer, void (*dealloc_func)(void *))

Packs data into a fio_stream_packet_s container.

Symbol type: function

#fio_stream_pack_fd

c
fio_stream_packet_s *fio_stream_pack_fd(int fd, size_t len, size_t offset, uint8_t keep_open)

Packs a file descriptor into a fio_stream_packet_s container.

Symbol type: function

#fio_stream_add

c
void fio_stream_add(fio_stream_s *stream, fio_stream_packet_s *packet)

Adds a packet to the stream. This isn't thread safe.

Symbol type: function

#fio_stream_pack_free

c
void fio_stream_pack_free(fio_stream_packet_s *packet)

Destroys the fio_stream_packet_s - call this ONLY if unused.

Symbol type: function

#fio_stream_read

c
void fio_stream_read(fio_stream_s *stream, char **buf, size_t *len)

Reads data from the stream (if any), leaving it in the stream.

buf MUST point to a buffer with - at least - len bytes. This is required in case the packed data is fragmented or references a file and needs to be copied to an available buffer.

On error, or if the stream is empty, buf will be set to NULL and len will be set to zero.

Otherwise, buf may retain the same value or it may point directly to a memory address within the stream's buffer (the original value may be lost) and len will be updated to the largest possible value for valid data that can be read from buf.

Note: this isn't thread safe.

Symbol type: function

#fio_stream_advance

c
void fio_stream_advance(fio_stream_s *stream, size_t len)

Advances the Stream, so the first len bytes are marked as consumed.

Note: this isn't thread safe.

Symbol type: function

#fio_stream_any

c
inline uint8_t fio_stream_any(fio_stream_s *stream)

Returns true if there's any data in the stream.

Note: this isn't truly thread safe.

Symbol type: function

#fio_stream_length

c
inline size_t fio_stream_length(fio_stream_s *stream)

Returns the number of bytes waiting in the stream.

Note: this isn't truly thread safe.

Symbol type: function