required/SRC680/dclocking : revised rtl/instance.hxx double-checked locking "static" helpers

[email protected] Wed, 21 Sep 2005 13:11:54 +0200 (CEST)
Newsgroups gmane.comp.openoffice.announce.interface
Message-ID <11753927.1127301114984.JavaMail.root@sd-web1>
Type
required

Title
revised rtl/instance.hxx double-checked locking "static" helpers

Posted by
[email protected]

Affected
,sal,svtools,vcl

Effective from
SRC680/dclocking

Summary

rtl/instance.hxx double-checked locking "static" helpers have been improved.

Description

Within cws dclocking the rtl/instance.hxx static helpers have been
improved:

- struct StaticInstance
o removed inheritance in Static, StaticAggregate:
referencing StaticInit, InitAggregate directly.
o removed third template parameter of Static
for custom init one can use new class StaticWithInit<>
(which also has not the drawback that the global mutex is acquired
during init)

There were only little changes to do on m56 (3 occurences in svtools,
vcl).

Info: new

+ template<typename T, typename InitData,
typename Unique = InitData, typename Data = T>
class StaticWithInit

helper base class for for a late-initialized static variable,
implementing the double-checked locking pattern correctly, use e.g.

struct MyStatic : public rtl::StaticWithInit<MyType, MyStatic> {
MyType operator () () {
...
return MyType( ...
}
};
...
MyType & rStatic = MyStatic::get();

For details have a look at rtl/instance.hxx.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]