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 you want the updates to be transactional) than using extensive locking.
--Chris On Mon, 2009-06-29 at 10:07 -0700, Jes wrote: > 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 moment through the network. > > > > I wonder if there is an easy way to transform the (derived) Messages > > into a thread-safe version. Maybe the rough solution could be to > > include a Mutex in the Message class and a MutexLock on each method of > > the generated pb.h and pb.cc classes, but perhaps there are issues > > that can break the safety of this approach (such as existing friends > > or similar). > > > > Could you have any suggestion on this? :-) > > > > Thanks in advance! > > > > Jes > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To post to this group, send email to protobuf@googlegroups.com To unsubscribe from this group, send email to protobuf+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/protobuf?hl=en -~----------~----~----~----~------~----~------~--~---