Print

Print


I believe the intent is to make sure that the local static Config (in getConfigHelper()) is initialized in a thread safe way (i.e. 2 threads don’t both try to call the constructor). In C++03, that isn’t actually guaranteed, but in C++11, it is (see e.g. http://stackoverflow.com/questions/8102125/is-local-static-variable-initialization-thread-safe-in-c11 <http://stackoverflow.com/questions/8102125/is-local-static-variable-initialization-thread-safe-in-c11>)

I think what you should do is remove configHelperFla, getConfigHelper() and callOnceHelper(), and change getConfig() to read:

Config & getConfig() {
    static Config c;
    return c;
}

> On May 7, 2015, at 10:12 PM, Jacek Becla <[log in to unmask]> wrote:
> 
> I'd also welcome help with migrating this line:
> 
> boost::once_flag configHelperFlag = BOOST_ONCE_INIT;
> 
> (it is in core/modules/wconfig/Config.cc)
> 
> std does not have equivalent, so it is a bit
> unclear how to migrate it (to me anyway)
> 
> Related reading
> http://stackoverflow.com/questions/4200813/stdonce-flag-equivalent-of-boost-once-init
> 
> Jacek
> 
> ########################################################################
> Use REPLY-ALL to reply to list
> 
> To unsubscribe from the QSERV-L list, click the following link:
> https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=QSERV-L&A=1


########################################################################
Use REPLY-ALL to reply to list

To unsubscribe from the QSERV-L list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=QSERV-L&A=1