leopard icon indicating copy to clipboard operation
leopard copied to clipboard

Implement Scratch-like sequencer behavior

Open adroitwhiz opened this issue 7 months ago • 3 comments

Depends on #210.

This PR makes a few changes as progress towards #212:

  • Instead of stepping each script once per frame, we do what Scratch does and keep going until a redraw is requested or we run out of frametime.
  • Therefore, requesting redraws has also been implemented. Most functions which cause something visual to change on-screen request a redraw.
  • The state that corresponds to a running script (namely the generator) has been moved out of Trigger and into its own class called Thread. Threads can:
    • Be "parked"--if it is waiting for a promise to resolve, it will park itself until the promise resolves.
    • Yield to another thread--that is, if the other thread is parked, the yielding thread will park itself as well, and ask the other thread to wake it up.
    • Be restarted in-place, without worrying about stale promise state.

Generator functions that are running as Leopard threads can await promises without having to be async themselves using the new Thread.await function.

adroitwhiz avatar Jul 17 '24 12:07 adroitwhiz