On Fri, Mar 6, 2009 at 6:41 PM, Marc Vaillant <[email protected]> wrote:

> Ok, thanks.  There are other problems though.  If A::b was a B* instead
> of a std::auto_ptr<B>, then the data that A::b points to will be ok
> because it won't be deleted.  However, A::b would get deleted so access
> to the data via A::b may be undefined.


If your global variables (and static members / static locals) are only POD
types then there's no problem.  The memory in which they reside will not be
unmapped or zeroed out until the process actually ends.


> Also I found that static vars local to the thread function get deleted
> before the thread gets killed.


Yep, same problem.


> Static is dangerous in multithreaded scenarios for obvious reasons.
> These issues just add more complications.


Static constants are not dangerous.  All of the data structures involved
here are built once and then become read-only for the life of the process.
 Static variables which are modified at runtime -- aka singletons -- are
very bad and should never be used.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to