------- Additional Comments From dhruvbird at yahoo dot com  2005-04-13 17:02 
-------
Subject: Re:  __gnu_cxx::bitmap_allocator export pruning


--- bkoz at gcc dot gnu dot org
<[EMAIL PROTECTED]> wrote:
> 
> ------- Additional Comments From bkoz at gcc dot gnu
> dot org  2005-04-13 16:32 -------
> I posit that this usage of static local variables,
> as written, is thread safe
> with gcc-4.0.x compilers. (Since resolution of
> c++/13684).
> 
> !     _Mutex*
> !     _M_get_mutex()
> !     {
> !       static _Mutex _S_mutex;
> !       return &_S_mutex;
> !     }
> 
> This object is only constructed (and initialized)
> once. After initial
> construction, a pointer to the initial object is
> returned. Don't let the
> simplicity of this solution fool you!
> 
> This change actually improves portability for
> initialization, especially on
> non-SVR4 platforms, where order of initalization of
> static objects may differ
> from expectations.

hmmm. then the code should be correct....

However, wrt efficiency, there will be a penalty
beause you need to acquire a mutex to acquire a mutex!
Ironical isn't it....

wrt initialization order, yes, this is definitely an
improvement.

Just as a thought, I was wondering if it could be made
global at the namespace level. then, all this wouldn't
matter, and initialization orders would also be
guaranteed....

OT: WRT the static initialization problem.

Also, to make the check on whether guard has been
set/reset, a lock must be prepended before it right?
So, that would stall the bus for some time....
Probably not what one would wish for ideally, but I'm
generally against the language protecting against
these kind of things.




> 
> -benjamin
> 
> 
> 
> 
> -- 
> 
> 
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20979
> 
> ------- You are receiving this mail because: -------
> You are on the CC list for the bug, or are watching
> someone who is.
> 

-Dhruv Matani
http://www.geocities.com/dhruvbird/


                
__________________________________ 
Do you Yahoo!? 
Yahoo! Small Business - Try our new resources site!
http://smallbusiness.yahoo.com/resources/


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20979

Reply via email to