Skip to content

Hide arcana behind pimpl in AppRuntime#154

Merged
bghgary merged 3 commits intoBabylonJS:mainfrom
bghgary:fix/appruntime-pimpl
Apr 14, 2026
Merged

Hide arcana behind pimpl in AppRuntime#154
bghgary merged 3 commits intoBabylonJS:mainfrom
bghgary:fix/appruntime-pimpl

Conversation

@bghgary
Copy link
Copy Markdown
Contributor

@bghgary bghgary commented Apr 14, 2026

[Created by Copilot on behalf of @bghgary]

Hide arcana implementation details behind a pimpl pattern in AppRuntime.

The Bug

PR #149 (Merge WorkQueue into AppRuntime) moved arcana includes into the public AppRuntime.h header. This exposed arcana/threading/cancellation.h and arcana/threading/dispatcher.h as transitive dependencies for all consumers, breaking builds in BabylonNative where arcana's include directories weren't propagated (PRIVATE link).

The Fix

Move the arcana-dependent members (cancellation_source, manual_dispatcher, thread, env, suspension lock) and the Append template into a private Impl class defined in AppRuntime.cpp. The public header no longer includes any arcana headers.

m_options stays on AppRuntime since platform-specific .cpp files access it directly.

Explicitly delete copy and move constructors/operators — the pimpl unique_ptr would otherwise make AppRuntime movable, but moving with a running thread and captured this pointers would be UB.

Thread Safety

The worker thread is joined in ~AppRuntime() before unique_ptr<Impl> is destroyed, preserving the same lifetime guarantees as before. No split-lifetime issues.

Verified

  • All 137 JS tests pass locally (Win32 V8)
  • DestroyDoesNotDeadlock test passes (210ms)

Move arcana types (cancellation_source, manual_dispatcher), thread,
env, suspension lock, and the Append template into a private Impl
class defined in AppRuntime.cpp. This keeps arcana out of the public
header so consumers don't need arcana's include directories.

The worker thread is joined before Impl is destroyed, preserving the
same lifetime guarantees as before.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 14, 2026 15:32
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR moves arcana-dependent implementation details out of the public Babylon::AppRuntime header and into a private PIMPL (AppRuntime::Impl) defined in AppRuntime.cpp, avoiding arcana threading headers becoming transitive dependencies for consumers.

Changes:

  • Introduces AppRuntime::Impl in AppRuntime.cpp to own the arcana dispatcher/cancellation/thread state and the internal Append helper.
  • Updates AppRuntime methods to delegate to m_impl for dispatching, suspension, cancellation, and thread joining.
  • Removes arcana threading includes and arcana-dependent members/templates from Core/AppRuntime/Include/Babylon/AppRuntime.h.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
Core/AppRuntime/Source/AppRuntime.cpp Adds AppRuntime::Impl containing arcana threading state and routes runtime operations through it.
Core/AppRuntime/Include/Babylon/AppRuntime.h Removes arcana headers and implementation details from the public API surface and introduces a forward-declared PIMPL pointer.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

bghgary and others added 2 commits April 14, 2026 08:41
The pimpl change made AppRuntime movable (unique_ptr is movable), but
moving an AppRuntime with a running thread and captured this pointers
in lambdas would be undefined behavior. Explicitly delete both copy
and move to match the previous implicit behavior.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@bghgary bghgary merged commit 8086014 into BabylonJS:main Apr 14, 2026
19 checks passed
@bghgary bghgary deleted the fix/appruntime-pimpl branch April 14, 2026 19:33
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.

3 participants