c++ - Do you need locking with only reading -
i wanted know safe assume if multiple threads accessing single static container (boost::unordered_map) there no need locking access container if multiple threads reading data it. , no writing done
when multiple threads reading , performing no write operation, not need synchronize access.
paragraph 1.10 of c++11 standard defines conflicting operations respect data races as:
two expression evaluations conflict if 1 of them modifies memory location (1.7) , other 1 accesses or modifies same memory location.
and of course, per 1.10/21:
the execution of program contains data race if contains 2 conflicting actions in different threads, @ least 1 of not atomic, , neither happens before other. [...]
Comments
Post a Comment