Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(share): use sync.Once instead of mutex for init #3625

Merged
merged 1 commit into from
Aug 5, 2024

Conversation

cristaloleg
Copy link
Contributor

We use share.EmptyRoot() in many places, concurrently. To get an empty root we need to take a mutex for a short time but why not to make it better by changing to a simple atomic check.

sync.Once exactly does this in a very lightweight way.

@cristaloleg cristaloleg added the kind:refactor Attached to refactoring PRs label Aug 5, 2024
Copy link
Member

@Wondertan Wondertan left a comment

Choose a reason for hiding this comment

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

good call

@renaynay renaynay merged commit 62190ac into main Aug 5, 2024
31 checks passed
@renaynay renaynay deleted the share/use-sync-once branch August 5, 2024 15:04
sebasti810 pushed a commit to sebasti810/celestia-node that referenced this pull request Aug 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:refactor Attached to refactoring PRs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants