||2 years ago|
|LICENSE||3 years ago|
|README.org||2 years ago|
|package.lisp||3 years ago|
|replay-streams.asd||3 years ago|
|replay-streams.lisp||3 years ago|
Replay streams let the programmer rewind to points in a stream that have already been read.
At the moment, replay streams only support character streams, but should someday support more exotic binary stream types.
NOTE: This is alpha quality software
The Replay Stream Types
The following clases are exported by the
static-text-replay-stream: This is the most efficient of the
replay-streamsclasses, and is analogous to
make-string-input-streamin that it transforms a string into a stream.
character-input-replay-stream: This is used to transform a characer input stream into a replayable stream. Suitable for reading files or character network streams.
The Replay Stream Interface
Each class in the
replay-streams package supports the following methods:
(checkpoint stream): returns a "checkpoint" which you can use to rewind to a specific point in your input stream.
(rewind-to stream checkpoint): is used to actually rewind a stream to a checkpoint.
(free-checkpoint stream checkpoint): tells the stream that it no longer needs to support rewinds to the supplied checkpoint.
actually do anything, but a dummy implementation is included to permit
general purpose code.
Support for rewinding streams is enabled by logging reads to the stream. As you might imagine, logging every read can begin to take its toll on the memory heap. Hence, freeing a checkpoint can signal to the stream that it may be acceptable to discard the log. Internally, the log is freed whenever there are no checkpoints remaining and when any playback on the log has been exhausted - i.e. whenever the system is certain that the log is no longer needed.
NOTE: As it stands right now, rewinding a stream to a checkpoint will also free that checkpoint and all checkpoints AFTER the rewind point.
This small library was created in order to support the parzival streaming
parser-combinator DSL, which needs replayable streams for its implementation
[0/4] To Do
Add a test suite.
character-input-replay-stream, support user control over initial log size.
character-input-replay-stream, support optional maximum log. size, along with an error condition if the log size is exceeded.
Support binary streams.