Oberon || Library || Module Index || Search Engine || Definition || Module
VAR mainTaskFinished: Events.EventType;
Not all modules which are linked together need to be initialized. This could be useful if the decision about the module selection depends on command line arguments or the environment.
The module bodies protect themselves against multiple executions and each module body calls the initialization part of all imported modules.
The default implementation of SysMain creates a task group of RoundRobin (which becomes the default task group of Tasks) and adds as first task a coroutine which initializes all modules in linkage order:
PROCEDURE InitAllModules; VAR module: SysModules.Module; BEGIN module := SysModules.modules; WHILE module # NIL DO module.init; module := module.next; END; END InitAllModules;
Note that SysMain, and, in consequence, the process does not necessarily terminate when InitAllModules terminates. SysMain returns when there are no living tasks of the main task group (InitAllModules is just one of these tasks).
The SysMain implementation is expected to raise an event of the type mainTaskFinished as soon as all modules are initialized. This gives all modules the opportunity to shutdown unneeded tasks to allow the process to terminate if no real activities continue.
Oberon || Library || Module Index || Search Engine || Definition || Module