I forgot to mention that we are generating C++ code in the project.
Jes
On 29 jun, 19:01, Jes damealpi...@hotmail.com wrote:
Hi everybody,
we are working on a distributed environment that uses PB, where
different threads will access to the contents of messages that can be
updated at any
I'd recommend using an atomic swap to do your updates. So you create
your new version of the PB localy, and then swap it in to the memory
location that is visible to all the other threads. The only real
downside is you stress the heap more, and that is probably
cheaper/simpler (particularly if
Simply adding a mutex lock in every accessor wouldn't really make them
thread-safe. Consider:
if (my_message.has_foo()) {
DoSomething(my_message.foo());
}
This is not thread-safe if my_message can be modified in a separate thread
*even if* each accessor locked a mutex, because foo could