Skip to content

state: add per-app instance(app&)/instancePtr(app&) overloads - #30

Merged
transfix merged 1 commit into
masterfrom
cvc-singleton/state-per-app-overload
May 3, 2026
Merged

transfix merged 1 commit into
masterfrom
cvc-singleton/state-per-app-overload

Conversation

@transfix

@transfix transfix commented May 3, 2026

Copy link
Copy Markdown
Owner

Phase D groundwork. Additive only.

Adds overloads that lazily create and cache a root state on the given app's data map, decoupling state ownership from app::instance(). Existing zero-arg state::instance() now delegates to instance(app::instance()) so all current callers (cvcstate macro included) preserve behavior.

Startup callbacks fire once per process via a one-shot guard.

Local: 590/590 tests pass. Lays groundwork for migrating xmlrpc_server and remaining singleton call sites to ctx-aware form before retiring the cvcstate macro and app::instance().

Adds additive overloads that lazily create and cache a root state
on the given app's data map, decoupling state ownership from
app::instance(). Existing zero-arg state::instance() now delegates
to instance(app::instance()), preserving behavior for all callers.

Startup callbacks still fire once per process. Future PRs can
migrate xmlrpc_server and other singleton callers to ctx-aware
form before the cvcstate macro is finally retired.
@transfix
transfix merged commit cf7ab80 into master May 3, 2026
19 checks passed
@transfix
transfix deleted the cvc-singleton/state-per-app-overload branch May 3, 2026 22:01
transfix added a commit that referenced this pull request May 4, 2026
…macro (#36)

All production and test callers now route through cvc::state::instance(app&)
(see PRs #30-#35). Remove the deprecated singleton API surface:

  - cvcstate macro (inc/cvc/state.h)
  - cvc::state::instance() zero-arg overload (declaration + definition)
  - cvc::state::instancePtr() zero-arg shim
  - state::_instance static cache and the &ctx == &app::instance()
    cache-write block in instancePtr(app&)

State roots are now exclusively per-app, stored on the app's data map
under "__state". 590/590 with CVC_USING_XMLRPC=ON and OFF locally.
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.

1 participant