Skip to content

fix: fix race condition for default engine init#273

Merged
devcrocod merged 2 commits intodevelopfrom
fix/default-engine-initialization
Feb 28, 2026
Merged

fix: fix race condition for default engine init#273
devcrocod merged 2 commits intodevelopfrom
fix/default-engine-initialization

Conversation

@devcrocod
Copy link
Copy Markdown
Collaborator

fixes #249

Checklist

  • Existing tests pass
  • New/updated tests for changed behavior
  • New/updated documentation if necessary

Copilot AI review requested due to automatic review settings February 28, 2026 00:52
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

Addresses #249 by making default engine selection safer under concurrent first access in Engine’s companion, reducing the chance of inconsistent/overwritten initialization across threads.

Changes:

  • Marked defaultEngine as @Volatile and added double-check logic in loadEngine().
  • Updated getDefaultEngine() to avoid expression-based initialization and use a local cached read.
  • Updated getMath() / getLinAlg() / getStatistics() to use a local engine snapshot and trigger lazy init when needed.

Comment thread multik-core/src/commonMain/kotlin/org/jetbrains/kotlinx/multik/api/Engine.kt Outdated
@devcrocod devcrocod merged commit 8f34400 into develop Feb 28, 2026
@devcrocod devcrocod deleted the fix/default-engine-initialization branch February 28, 2026 01:58
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.

Fix race condition in Engine default initialization

2 participants