-
Notifications
You must be signed in to change notification settings - Fork 229
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
feat: make Lipgloss Style thread-safe #139
Conversation
Here's one thing I dislike about my own change: this doesn't protect the With that being said, maybe an exclusive |
This this is great. It doesn’t appear to impact performance much and the thread-safety it brings is a pretty big deal. |
This eliminates the chance of ever accessing an uninitialized map, which caused a few bugs in the past. The performance impact of this seems barely measurable.
Since we had a few reports about concurrently accessing base style definitions, I figured one solution would be making
Style
's rules map thread-safe. While it's an elegant solution, it is a trade-off: it guards against crashes from concurrent access, but that obviously slows down access by a tiny bit. I don't think the impact is too bad, though, and not crashing is always nice.go test -bench=. -benchtime=30s
Before change:
With
sync.map
: