Efficient UNO component linkage & GC ...

Stephan Bergmann sbergman at redhat.com
Thu Jan 16 00:11:07 PST 2014


On 12/19/2013 10:51 AM, Stephan Bergmann wrote:
> * for implementations of single-instance services/singletons, we can:
>
> ** either stick with the recently introduced prefix="direct" feature,
> where the service manager obtains a factory for them; any instantiated
> object instances will continue to be disposed well ahead of exit via
> disposing the ComponentContext in desktop::Desktop::DeInit
> (desktop/source/app/app.cxx)
>
> ** or also use the constructor="..." feature, in which case the
> individual constructor functions would need to hold a single instance,
> which could postpone that instance's destruction to atexit, with all
> dreaded consequences (an option might be to hold the single instance
> weakly)
>
> ** or use some <implementation single-instance="true" flag in .component
> XML and implement the logic of holding a single instance in the service
> manager, which would dispose them when it gets disposed well ahead of exit

Update:  "True singletons" (i.e., implementations for which a .component 
file lists a <singleton ...>) are always disposed when the component 
context is disposed (see how ComponentContext::disposing, 
cppuhelper/source/component_context.cxx, "dispose[s] all context 
objects" and how cppuhelper::ServiceManager::addSingletonContextEntries, 
cppuhelper/source/servicemanager.cxx, registers all those "true 
singletons" at the component context upon bootstrap).  That makes the 
third option above less attractive, as it would cause double dispose of 
them, once from the service manager and once from the component context 
(not that it would typically be harmful to do a double dispose on a UNO 
object, but still).

And given that "false singletons" (i.e., services that are implemented 
with single-instance factories) are a misfeature and should arguably be 
replaced by "true singletons," I think I see a way out.

Let me experiment a little and stay tuned...

Stephan


More information about the LibreOffice mailing list