Skip to content

v1.1.2 - Global FlushEngine

Choose a tag to compare

@Adam4lexander Adam4lexander released this 14 Aug 11:45
· 158 commits to main since this release

This release focuses on FlushEngine (previously SpokeEngine), and the choice to have a global engine for all behaviours, or each behaviour having its own. In past releases, every SpokeBehaviour had its own FlushEngine. This lets an engine flush, and during its flush trigger another to engine flush, resulting in a nested flush. This is powerful, but dangerous if not careful. The default now is a single global FlushEngine at the root of all SpokeBehaviour engines, so only one can flush at a time.

Nested flushing is still possible by creating seperate trees with SpokeRoot.Create(new FlushEngine(...)). But this is now an advanced opt-in feature, not the default.

Another important change is s.Export and s.Import. Example:

s.Effect(s => {
    s.Export(new SomeResource());
    s.Effect(s => {
        var resource = s.Import<SomeResource>();
    });
});

Exported objects are visible on the lexical scope. All descendants and later siblings can import it.

Changelist:

  • SpokeEngine renamed to FlushEngine, and the base class ExecutionEngine takes the name SpokeEngine
  • FlushEngine.Batch() is a static method that holds all engines from flushing. It replaces the per-engine batching
  • FlushEngine.Global is one engine that all SpokeBehaviour will attach to. The implication is only one SpokeBehaviour has flush at once
  • FlushEngine.AddFlushRegion lets you conveniently attach a nested FlushEngine under another. This is what SpokeBehaviour is using
  • s.Export and s.Import replaces TryGetLexical and TryGetContext
  • Correctly handle Epochs that dispose their own root, or drop themselves from a dock mid-execution
  • Correctly order all Call, OnCleanup and Use resources in a single array. Now they are truly disposed in reverse-declaration order