Can Q_GLOBAL_STATIC replace KStaticDelete ?
thiago at kde.org
Thu Jan 18 19:43:52 GMT 2007
Matthias Kretz wrote:
>/me leans towards dropping thread safety for K_GLOBAL_STATIC. Use
>Q_GLOBAL_STATIC if you want thread safety or if we really shouldn't use
>Q_GLOBAL_STATIC like Simon wrote, create a K_GLOBAL_STATIC_THREADSAFE
> (or so).
Simon also said we can use QBasicAtomicPointer, so we can implement the
thread-safety if we want.
I propose instead the following:
K_GLOBAL_STATIC, with the same semantics as Q_GLOBAL_STATIC (i.e.,
thread-safe), but with an extra parameter: an enum. The enum indicates
when the destruction should happen.
K_GLOBAL_STATIC(QStringList, names, KDE::DestroyOnExit)
K_GLOBAL_STATIC(KInstance, instance, KDE::DestroyWithApplication)
K_GLOBAL_STATIC(KSomething, something, KDE::DestroyWithInstance)
Another reason why I oppose destruction-with-application or instance: what
happens if the application restarts? It can happen in some cases in which
the same process creates and destroys QCoreApplication more than once.
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