Skip to content
This repository was archived by the owner on Jan 31, 2026. It is now read-only.

Comments

Fix Interlocked.CompareExchange pattern to use explicit comparison#16

Closed
Copilot wants to merge 2 commits intobug/thread-not-startedfrom
copilot/sub-pr-8-yet-again
Closed

Fix Interlocked.CompareExchange pattern to use explicit comparison#16
Copilot wants to merge 2 commits intobug/thread-not-startedfrom
copilot/sub-pr-8-yet-again

Conversation

Copy link
Contributor

Copilot AI commented Nov 23, 2025

The Interlocked.CompareExchange calls used negation (!) instead of explicit comparison, reducing clarity for atomic compare-and-swap operations.

Changes

  • Changed !Interlocked.CompareExchange(ref _initialized, true, false) to Interlocked.CompareExchange(ref _initialized, true, false) == false at both initialization check points (lines 133, 157)

The explicit == false pattern makes the intent clear: execute the block if the original value was false, which is the value returned by CompareExchange.

// Before
if (!Interlocked.CompareExchange(ref _initialized, true, false))
{
    InitializeHaptics();
}

// After  
if (Interlocked.CompareExchange(ref _initialized, true, false) == false)
{
    InitializeHaptics();
}

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

…gation

Co-authored-by: nalathethird <36301692+nalathethird@users.noreply.github.com>
Copilot AI changed the title [WIP] WIP address feedback from PR #8 on bHapticsManager enhancements Fix Interlocked.CompareExchange pattern to use explicit comparison Nov 23, 2025
Copilot AI requested a review from nalathethird November 23, 2025 03:45
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants