Can Q_GLOBAL_STATIC replace KStaticDelete ?
thiago at kde.org
Thu Jan 18 22:45:11 GMT 2007
Matthias Kretz wrote:
>The problem is that if thread 1 inits this_##NAME and then executes the
> code in the macro (creating a new object and returning it) while thread
> 2 does the same, the internal flag that the local static has been
> initialized might still be unset so that thread 2 creates a second
> QGlobalStatic object which tells the macro that the object has not been
> created yet.
That's what I said :-)
And that's where QBasicAtomicPointer comes in (not QAtomicPointer because
that isn't POD). It allows us to atomically set the pointer without the
need for a guard variable.
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
PGP/GPG: 0x6EF45358; fingerprint:
E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 189 bytes
Desc: not available
More information about the kde-core-devel