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 <[email protected]>
- Loading branch information