Skip to content

A library for manipulating linked buffers within a queue.

License

Notifications You must be signed in to change notification settings

laplacedoge/bufferqueue

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Table of contents

Introduction

A library for manipulating linked buffers within a queue.

Abilities

What you can do with it?

  • Use bque_new() to create a new buffer queue.
  • Use bque_enqueue() to add a buffer to the end of the queue.
  • Use bque_dequeue() to remove a buffer from the beginning of the queue.
  • Use bque_stat() to get the status information of a buffer queue.
  • Use bque_empty() to remove all buffers from the queue.
  • Use bque_free() to free a buffer queue.

What you can EVEN do with it?

  • Use bque_preempt() to add a buffer to the beginning of the queue.
  • Use bque_forfeit() to remove a buffer from the end of the queue.
  • Use bque_item() to get the buffer at a specific position in the queue.
  • Use bque_insert() to add a buffer to the queue at a specific position.
  • Use bque_drop() to remove a buffer from the queue at a specific position.

And sure it can also...

  • Use bque_sort() to sort the buffers in the queue using your own sorting rule.
  • Use bque_foreach() to iterate through the buffers in the queue forwardly or backwardly.

Usage

Create a bque context

bque_ctx *ctx;
bque_res res;

res = bque_new(&ctx, NULL);
if (res != BQUE_OK) {
    /* Failed to create the bque context.
       Check the value of `res` for details. */
}

Configure your context

/* Unlimited number of buffers. */
int max_buff_num = 0;

/* Maximum buffer size of 1K bytes. */
int max_buff_size = 1024;

bque_adjust(ctx, BQUE_OPT_SET_MAX_BUFF_NUM, &max_buff_num);

bque_adjust(ctx, BQUE_OPT_SET_MAX_BUFF_SIZE, &max_buff_size);

Free your context

bque_free(ctx);

About

A library for manipulating linked buffers within a queue.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published