Date: prev next · Thread: first prev next last
2014 Archives by date, by thread · List index


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

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.