WebAssembly/decompressor-prototype

Simplifying Queue and Pipe data structures.

KarlSchimpf opened this issue · 0 comments

The original intent of the Queue data structure was do define a data structure that allowed simultaneous reading and writing to it.

The "Queue.FirstPage" field was used to automatically clean up when streaming. However, because there was only one first page for both reading and writing, the Pipe concept could not be implemented.

A better solution is to add a "read" first page and a "write" first page concept. Each of these (shared) pointers keep track of the portion of the queue that is being used for reading and writing. Either page pointer may be null, if the corresponding concept is not being used.

If there is both a "read" and a "write" first page, the "read" page should always be behind the "write" first page, unless "eof" has been frozen (in which case the remainder of the input can be read).

In addition, advancement of read cursors should be limited to pages that appear before the first write page (only applies if first write page is non-null). This guarantees that the input is no longer changing.