[Qt-interest] Initializing application modules in sequence

Mandeep Sandhu mandeepsandhu.chd at gmail.com
Mon Apr 25 13:12:45 CEST 2011


Hi All,

I'm working on a fairly large Qt app for an embedded Linux platform.

Before the application presents any UI to a user, we have to
initialize the various application modules that the app uses. Some of
these modules do n/w IO, some init a h/w interface in a specific
manner etc.

Roughly, the following rules should be adhered to while calling init's
on different modules:

1. The initialization routines of the various modules should be called
in a pre-determined, specific order (eg:  the order in which are
placed in a list)

2. The overall initialization is considered to be done, IFF _all_
modules have been initialized.

3. There should be a way to specify if the initialization of a module
should be blocking or non-blocking. Eg: if a module (module-A)
requires some n/w IO to be completed (which might take time), then
such an init can be marked as "non-blocking", where other succeeding
modules init are called w/o waiting for this to complete. Though the
overall init is considered done only when module-A completes. The
reason for keeping certain init's non-blocking is to have the overall
init time as small as possible by trying to do independent things in
parallel.

4. Because of the blocking/non-blocking behavior, we will also need to
specify a 'dependency' for the initialization of a module. eg:
module-C (done in say, step 3 of init procedure), can depend on
module-A to be initialized (which is step-1), but step-1 was done in a
non-blocking mode. So, we will have to wait for step-1 to complete
before we attempt to init module-C in step 3.

Prior to using QT, I used to work in a C-based embedded environment,
where we had a very simple "Init table", where ppl used to add their
functions (the init table was a simple array of function pointers) in
the order in which they wished to be called. So taking my example
above, if you need module-A to be init'ed before module-C, you add
module-C in the array at an index _after_ module-A's. Though here,
there was no concept of a non-blocking init routine.

Does Qt provide any convenience classes for handling such problems?

Have you also faced this or a similar issue? If so, how did you handle it?

Thanks,
-mandeep



More information about the Qt-interest-old mailing list