Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: make static data variable threadsafe
I've hit a bug developing a go parser and running multiple instances of it with t.Parallel() Turned out that staticData var was a global and would throw concurrent data access errors when running the test suite with -race This commit fixes it by doing the following: 1. turn <parser.grammarName; format="cap">ParserStaticData into a struct 2. Teach <parser.name; format="cap">Init() to return a pointer to new instance of this struct 3. Teach <parser.name; format="cap">Init() to initialize it upon construction I've been able to run 10000 concurrent parsers in this setup without having any performance/memory usage problem Signed-off-by: Tomasz Nguyen <me@swistofon.pl> Signed-off-by: Tomasz Nguyen <tonguyen@confluent.io>
- Loading branch information
Showing
1 changed file
with
18 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters