2004-06-08 23:54:24 +00:00
|
|
|
#ifndef foomemblockqhfoo
|
|
|
|
|
#define foomemblockqhfoo
|
|
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
|
|
|
|
|
#include "memblock.h"
|
2004-07-03 00:19:17 +00:00
|
|
|
#include "memchunk.h"
|
2004-06-08 23:54:24 +00:00
|
|
|
|
|
|
|
|
struct memblockq;
|
|
|
|
|
|
2004-07-03 00:19:17 +00:00
|
|
|
/* Parameters: the maximum length of the memblock queue, a base value
|
|
|
|
|
for all operations (that is, all byte operations shall work on
|
|
|
|
|
multiples of this base value) and an amount of bytes to prebuffer
|
|
|
|
|
before having memblockq_peek() succeed. */
|
2004-06-15 00:29:01 +00:00
|
|
|
struct memblockq* memblockq_new(size_t maxlength, size_t base, size_t prebuf);
|
2004-07-03 00:19:17 +00:00
|
|
|
void memblockq_free(struct memblockq*bq);
|
2004-06-08 23:54:24 +00:00
|
|
|
|
2004-07-03 00:19:17 +00:00
|
|
|
/* Push a new memory chunk into the queue. Optionally specify a value for future cancellation. This is currently not implemented, however! */
|
|
|
|
|
void memblockq_push(struct memblockq* bq, const struct memchunk *chunk, size_t delta);
|
2004-06-08 23:54:24 +00:00
|
|
|
|
2004-07-03 00:19:17 +00:00
|
|
|
/* Same as memblockq_push(), however chunks are filtered through a mcalign object, and thus aligned to multiples of base */
|
|
|
|
|
void memblockq_push_align(struct memblockq* bq, const struct memchunk *chunk, size_t delta);
|
|
|
|
|
|
|
|
|
|
/* Return a copy of the next memory chunk in the queue. It is not removed from the queue */
|
2004-06-08 23:54:24 +00:00
|
|
|
int memblockq_peek(struct memblockq* bq, struct memchunk *chunk);
|
2004-07-03 00:19:17 +00:00
|
|
|
|
|
|
|
|
/* Drop the specified bytes from the queue */
|
2004-06-08 23:54:24 +00:00
|
|
|
void memblockq_drop(struct memblockq *bq, size_t length);
|
|
|
|
|
|
2004-07-03 00:19:17 +00:00
|
|
|
/* Shorten the memblockq to the specified length by dropping data at the end of the queue */
|
2004-06-08 23:54:24 +00:00
|
|
|
void memblockq_shorten(struct memblockq *bq, size_t length);
|
2004-07-03 00:19:17 +00:00
|
|
|
|
|
|
|
|
/* Empty the memblockq */
|
2004-06-08 23:54:24 +00:00
|
|
|
void memblockq_empty(struct memblockq *bq);
|
|
|
|
|
|
2004-07-03 00:19:17 +00:00
|
|
|
/* Test if the memblockq is currently readable, that is, more data than base */
|
2004-06-15 00:29:01 +00:00
|
|
|
int memblockq_is_readable(struct memblockq *bq);
|
2004-07-03 00:19:17 +00:00
|
|
|
|
|
|
|
|
/* Test if the memblockq is currently writable for the specified amount of bytes */
|
2004-06-15 00:29:01 +00:00
|
|
|
int memblockq_is_writable(struct memblockq *bq, size_t length);
|
2004-06-08 23:54:24 +00:00
|
|
|
|
2004-07-03 00:19:17 +00:00
|
|
|
/* The time memory chunks stay in the queue until they are removed completely in usecs */
|
2004-06-18 17:12:50 +00:00
|
|
|
uint32_t memblockq_get_delay(struct memblockq *bq);
|
2004-07-03 00:19:17 +00:00
|
|
|
|
|
|
|
|
/* Return the length of the queue in bytes */
|
2004-06-18 17:12:50 +00:00
|
|
|
uint32_t memblockq_get_length(struct memblockq *bq);
|
2004-06-15 15:18:33 +00:00
|
|
|
|
2004-07-03 00:19:17 +00:00
|
|
|
/* Return how many bytes are missing in queue to the specified fill amount */
|
2004-06-23 23:17:30 +00:00
|
|
|
uint32_t memblockq_missing_to(struct memblockq *bq, size_t qlen);
|
|
|
|
|
|
2004-06-08 23:54:24 +00:00
|
|
|
#endif
|