diff options
author | Jarek Kobus <jaroslaw.kobus@qt.io> | 2021-09-17 16:32:50 +0200 |
---|---|---|
committer | Jarek Kobus <jaroslaw.kobus@qt.io> | 2021-09-28 10:25:29 +0000 |
commit | 7958de05f5837b578490c667b255b2bad2166af5 (patch) | |
tree | 8101aa3b465f0132d2618f2fae1e20ebe6afb4ca /src/libs/utils/utils.qbs | |
parent | 03f6de1eeb26a9b88df250f136cb6f90216ac68d (diff) |
Introduce Utils::Singleton
Introduce Utils::Singleton class and
Utils::SingletonWithOptionalDependencies class template
that helps implementing singletons that depend on other
singletons. It's guaranteed that whenever singleton B depends
on singleton A, than A is always created before B is being
created, and that the order of destruction is always
opposite to the order of creation.
Dependencies of singleton are listed as template arguments
for SingletonWithOptionalDependencies class template.
The first argument of SingletonWithOptionalDependencies
class template is always a singleton class itself.
Prepare a common interface for all singleton subclasses:
SingletonSubClass *SingletonWithOptionalDependencies::instance();
Make instantiating singletons and its dependencies thread-safe.
Create singletons on demand (only if some code needs them).
It's not needed anymore to explicitly instantiate
all required singletons in tests.
Make it possible (and thread-safe) to instantiate ProcessReaper
and LauncherInterface singletons in non-main threads.
Make the following dependencies between existing singletons:
SshConnectionManager depends on:
-> LauncherInterface depends on:
-> ProcessReaper
Change-Id: Iefaacab561c2b3dcf07e7fafbb87339ea6a15278
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'src/libs/utils/utils.qbs')
-rw-r--r-- | src/libs/utils/utils.qbs | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/libs/utils/utils.qbs b/src/libs/utils/utils.qbs index e6b1d0621dd..77f80dd81b8 100644 --- a/src/libs/utils/utils.qbs +++ b/src/libs/utils/utils.qbs @@ -264,6 +264,8 @@ Project { "shellcommand.h", "shellcommandpage.cpp", "shellcommandpage.h", + "singleton.cpp", + "singleton.h", "sizedarray.h", "smallstring.h", "smallstringiterator.h", |