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

fix: concurrent styles map access #650

Closed
wants to merge 1 commit into from

Conversation

aymanbagabas
Copy link

Use sync.Map to avoid concurrent map access "concurrent map writes"
fatal error.

Use sync.Map to avoid concurrent map access "concurrent map writes"
fatal error.
@alecthomas
Copy link
Owner

Thanks for the PR, but I don't think this is the right approach:

  1. It is an API breaking change.
  2. It only makes style registration concurrent, not lexers or formatters.
  3. Chroma is not designed to be concurrent safe.

My suggestion would be to either maintain your own registry (it's just a convenience map), or pull the locking up to a higher level.

@alecthomas alecthomas closed this Jul 12, 2022
@alecthomas
Copy link
Owner

That said, the LexerRegistry is a different case and making it concurrent safe does make sense as it's part of the lexer API and can't be worked around.

aymanbagabas added a commit to charmbracelet/soft-serve that referenced this pull request Jul 27, 2022
aymanbagabas added a commit to charmbracelet/soft-serve that referenced this pull request Jul 28, 2022
aymanbagabas added a commit to charmbracelet/soft-serve that referenced this pull request Aug 2, 2022
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.

2 participants