OUT OF DATE; LAYERS IS MULTITHREADED NOW

Current layer processing

The Layers class is single threaded currently. At initialization, it sets its variables and sorts provided marks into their layers.

When produceSpanData is called, Layers will press all layers together into a span data array. It calls for a pressLayersBtwn on the entire text.

When patchSpanData is called, it is more complicated. We do not want to patch the entire text, so we need to find the affected section of the span data array.

In pressLayersBtwn, we need to take the existing layers and turn it into span data.

New layer processing

The single threaded part is the main issue to solve. We can put up with complication, but not sloth; a lot of this processing is async-able.

Generally, here are some steps we can take toward async:

  1. Async patch as much as possible
  2. Use patch to do the initial "produceSpanData" calculation as well
  3. Add a DieCut structure to take the initial press and cut it into separate pieces
  4. Synchronize Manuscript's spanDataArray using setTimeout or something, 100ms or so

In order, with full multithreading, here is what we should do. Let's look first by thread.

Main Thread

Mark Patch Thread

Span Patch thread

Synchronization