[Qt-interest] Initializing application modules in sequence

Mandeep Sandhu mandeepsandhu.chd at gmail.com
Tue Apr 26 13:43:53 CEST 2011


Hi Frank,

Thanks for the detailed example.

>
> The cost:  At start-up you spawn off a bunch of threads to get these
> singletons, most of which merely block until some other thread has
> initialized the singleton in question.

There might one limitation with threads though. What if some
initialization requires you to do things specifically from the main
thread only (eg: some pixmap manipulation which can be done only from
the main thread context)? Though I don't have such a case right now
for my init's.

>
> The advantages:  Nobody has to keep track as to whether some
> initializations are blocking and others non-blocking, and you still
> get maximum benefit of letting "non-blocking" initializations run
> simultaneously.  No central dependency manager has to keep track
> of dependencies or in which order to run the initializations.  Each
> service needs only know of its immediate dependencies, and,
> provided you have no cyclic dependencies (which would cause
> you grief in any of the schemes discussed), you get exactly the
> ordering of initializations you need.  To add a new service, you
> only need to provide code for the service itself, only requiring that
> the new service initialize its immediate dependencies.

Somehow, in this case, I like the idea of a central point of control.
Every init/service should not have to be "recoded" if a dependency
changes or is removed. I'd prefer if such responsibility is delegated
to one 'controller' only. init/service routine writers just bother
about writing their specific code and declare the dependencies, w/o
needing to know how/when it will be met.

Though this approach has the most parallelism possible of all
approaches (short of making it multi-process! :)).

Thanks again.

-mandeep

>
>
> Happy Hacking!
>
>
> K. Frank
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at qt.nokia.com
> http://lists.qt.nokia.com/mailman/listinfo/qt-interest
>



More information about the Qt-interest-old mailing list