Skip to content

Conversation

@Arunodoy18
Copy link

@Arunodoy18 Arunodoy18 commented Nov 16, 2025

This PR introduces a thread-safe initialization mechanism for SingletonBase to prevent race conditions during concurrent object creation. The implementation follows a double-checked locking pattern to ensure correctness and minimize unnecessary synchronization overhead.
The previous implementation was vulnerable to race conditions because multiple threads could enter call simultaneously and each create its own instance.
This led to:

inconsistent singleton state

potential corruption of shared resources

unpredictable behavior during parallel execution

The new implementation ensures exactly one instance is created—even under high concurrency—without introducing unnecessary overhead.

@Arunodoy18 Arunodoy18 marked this pull request as ready for review November 16, 2025 17:37
@Arunodoy18
Copy link
Author

Hi, I’ve opened a PR fixing this issue: #86.
Please let me know if any adjustments are needed.

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