Skip to content

Improve JFactory state machine#491

Merged
nathanwbrei merged 10 commits intomasterfrom
nbrei_jfactory_state_machine
Mar 29, 2026
Merged

Improve JFactory state machine#491
nathanwbrei merged 10 commits intomasterfrom
nbrei_jfactory_state_machine

Conversation

@nathanwbrei
Copy link
Copy Markdown
Collaborator

This PR redesignes the JFactory state machine, as described in docs/behavior.md, to better enforce a number of guarantees regarding if and when JFactory callbacks get run.

  • It fixes bugs:

  • It correctly handles a number of previously unconsidered edge cases

    • Inserting data into a factory after Init() has excepted
    • Inserting() data into a factory on one event, but relying on Process() on another event in the same stream
    • Guaranteeing that Init() doesn't get called if Process() never does
  • It changes behavior:

    • Once JFactory::Init excepts, it is never called again. Instead, the exception is stored and re-thrown
    • Once JFactory::Process (and BeginRun, etc) except, it won't be called again until ClearData() is called in preparation for the next JEvent
  • It reduces code complexity:

    • The decayed and redundant JFactory::CreationStatus is removed completely
    • Factoring JFactory::InitStatus out from JFactory::Status simplifies logic elsewhere

veprbl and others added 9 commits March 29, 2026 13:40
Previously, JFactory::Create() would let DoInit() throw without calling JPodioOutput::LagrangianStore(). This leaves the podio::Frame in a bad state where collections are null instead of empty.
This fixes a longstanding source of confusion in the codebase, and paves the way for storing callback exceptions
This separates the concern of "Has Init() run?" (which is sticky across ClearData()) from "Where did the data, if any, come from?", which is not
Previously, it would re-run the excepting code instead.
@nathanwbrei nathanwbrei force-pushed the nbrei_jfactory_state_machine branch from 1e94852 to 97bb307 Compare March 29, 2026 17:40
@nathanwbrei nathanwbrei merged commit a3b9074 into master Mar 29, 2026
16 checks passed
@nathanwbrei nathanwbrei deleted the nbrei_jfactory_state_machine branch March 29, 2026 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants