No description
Find a file
Marc Azar 6a6b917740
Update README.md
Signed-off-by: Marc Azar <marc.azar@gmail.com>
2019-06-04 17:53:18 +03:00
docs Add isNil for read function 2019-06-04 17:49:56 +03:00
src Add isNil for read function 2019-06-04 17:49:56 +03:00
tests Add isNil for read function 2019-06-04 17:49:56 +03:00
.gitignore Add gitignore 2019-03-21 20:51:27 +02:00
_config.yml Create _config.yml 2019-02-28 15:35:21 +02:00
bipbuffer.nimble Change nimble version 2019-06-04 17:51:32 +03:00
LICENSE Initial commit 2019-02-24 11:46:36 +02:00
README.md Update README.md 2019-06-04 17:53:18 +03:00

BipBuffer

A Nim implementation of Simon Cooke's Bip Buffer. A Bi-partite buffer is similar to a circular buffer, but where data is inserted in two revolving regions. This allows reads to return contiguous blocks of memory, even if they span a region that would normally include a wrap-around in a circular buffer. It's especially useful for APIs requiring blocks of contiguous memory, eliminating the need to copy data into an interim buffer before use.

Example Usage

import bipbuffer

var buffer = newBipBuffer[int](4) # Create buffer wuth capacity of 4 int items
 
 block:
  var reserved = buffer.reserve(4)  # Reserve 4 slots for insert on buffer
  reserved[0] = 7 # Assign data to buffer slots
  reserved[1] = 22
  reserved[2] = 218
  reserved[3] = 56

buffer.commit(4)  # Commit reserved data into an available region on buffer

block:
  var bloc = buffer.read # Get stored data in a contiguous block
  assert bloc[0] == 7
  assert bloc[1] == 22
  assert bloc[2] == 218
  assert bloc[3] = 56

buffer.decommit(2)  # Mark first two parts of the block as free

block:
  var bloc = buffer.read # The block should now contain only the last two values
  assert bloc[0] == 218
  assert bloc[1] == 56

Installation

Install Nim for Windows or Unix by following the instructions in , or preferably by installing choosenim

Once choosenim is installed you can nimble install bipbuffer to pull the latest bipbuffer release and all its dependencies

Documentation

Documentation can be found here