Guile: (buffer repository)

In a step towards constructing my block-programming framework, I coded this (buffer repository) module:

(buffer repository)
(buffer repository tests)

(make-buffer-repository smallest-pwr largest-pwr)

 A procedure in module (buffer repository).
 Make a buffer repository instance. Parameters refer to the sizes of buffers
  stored in the repository. The smallest size is 2 to the smallest-pwr, the
  largest is 2 to the largest-pwr. 

(checkout-buffer! requested-bytes (buffer-repository) (#:spawn))

A procedure in module (buffer repository).

Checkout a buffer (bytevector) from the buffer-repository. If
 buffer-repository is not specified, parameter %buffer-repository is
 used. The default action, if a buffer is not available from the
 appropriate size bucket, is to generate a new buffer. If #:spawn #f is
 passed, checkout-buffer! will throw the 'empty-bucket exception
 instead. The buffer returned might be larger than the number of bytes
 requested. A 'no-match exception will be thrown if the size-requested
 is not in the range of buffer sizes stored by the buffer-repository.

(checkin-buffer! buffer (buffer-repository))

A procedure in module (buffer repository).

Return a buffer (bytevector) to the buffer-repository. If
 buffer-repository is not specified, parameter %buffer-repository is
 used. It is the responsibility of the calling code not to use the
 buffer after it has been checked in. Technically the buffer does not
 have to be one that was originally checked-out from the
 buffer-repository, but checkin-buffer will throw exceptions if the
 buffer is not the proper size to fit in a repository bucket.

git clone git://git.librehacker.com/pub/git/hackrf-rkt.git

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s