Closed vityaman closed 1 month ago
Correct. Since TypeScript single threaded there's no need to make global variables (caches etc.) thread safe. For languages like Java and C++ this must be added explicitly. The easiest way is probably to use thread_local
(C++) or ThreadLocal<>
(Java).
It seems to me that the current implementation is not thread safe because of a global variable used in rule processing. As I understand, this
std::map
is some kind of cache ofFollowSetsPerState
.This was one of the reasons for starting work on the C++ port in #132.
std::map
is not thread safe, so it should be guarded by somestd::mutex
or be madethread_local
, likeDFA
cache inANTLRv4
.It should be noticed that I did these conclusions only by reading the code and did not test it, so the task should be studied firstly.