Sack Library Documentation
sack::app::deadstart Namespace

Application namespace. These are compiler-platform abstractions to provide a method of initialization that allows for creation of threads, and transparent (easy to use) method of scheduling routines for initialization.

In some compilers and compile modes this is also fairly easy to do. A lot of compilers do not offer priority, and are impossible to maintain an order in. Some compilers only provide startup priority for C++ mode. This system works as long as there is a way to run a single function at some point before main() and after C runtime initializes. 


In Windows, you might think you have this ability with DllMain, but there are severe limitations that you would have to get around; primary is the inability to create a thread, well, you can create it, but it will remain suspended until you leave DllMains and all DllMains finish. There is also no way to consistantly provide initialization order, like memory needs to be initialized before anything else.

This schedules a routine to run at startup. Fill in the routine with the code you want, and it will run at DEFAULT_PRELOAD_PRIORITY which is the number 69. 


PRELOAD( MyCustomInit )
    // do something here (do anything here,
    // without limitations that are imposed by DllMain/LibMain.


If you wanted a routine which was guaranteed to run before MyCustomInit you might use PRIORITY_PRELOAD whcih allows you to specify a priority.

   // this will run before other things.


Priorities are listed in deadstart.h and exit_priorities.h. The priorities are treated backwards, so low number startup priorities go first, and higher number shutdown priorities go first. 


The following table lists functions in this documentation. 
The following table lists macros in this documentation. 
call this after a fork(). Otherwise, it will falsely invoke shutdown when it exits. 
Not usually used by user code, but this invokes all the routines which have been scheduled to run for startup. If your compiler doesn't have a method of handling deadstart code, this can be manually called. It can also be called if you loaded a library yourself without using the LoadFunction interface, to invoke startups scheduled in the loaded library. 
This just calls the list of shutdown procedures. This should not be used usually from user code, since internally this is handled by catching atexit() or with a static destructor. 
returns whether MarkRootDeadstartComplete has been called. 
This is typically called after the first InvokeDeadstarts completes. The code that runs this is usually a routine just before main(). So once code in main begins to run, all prior initialization has been performed. 
Used by ATEXIT and PRIORITY_ATEXIT macros to register a shutdown routine at a specific priority. Higher number priorities are scheduled to run before lower number priorities. *backwards from PRELOAD priorities* This registers functions which are run while the program exits if it is at all able to run when exiting. calling exit() or BAG_Exit() will invoke these. 
Used by PRELOAD and PRIORITY_PRELOAD macros to register a startup routine at a specific priority. Lower number priorities are scheduled to run before higher number priorities*backwards from ATEXIT priorities*. Using this scheduling mechanisms, routines which create threads under windows are guaranteed to run before main, and are guaranteed able to create threads. (They are outside of the loader lock) 
Resumes a suspended deadstart. If root deadstart is completed, then ResumeDeadstart will call InvokeDeadstarts after resuming deadstart. 
This routine is used internally when LoadFunction is called. After MarkDeadstartComplete is called, any call to a RegisterPriorityStartupProc will call the startup routine immediately instead of waiting. This function disables the auto-running of this function, and instead enques the startup to the list of startups. When completed, at some later point, call ResumeDeadstart() to dispatched all scheduled routines, and release the suspend; however, if initial deastart was not dispatched, then ResumeDeadstart does not do the invoke, it only releases the suspend. 
Basic way to register a routine to run when the program exits gracefully. 
A macro to define some code to run during program shutdown. An additional priority may be specified if the order matters. Higher numbers are called first. 
this is just a global space initializer (shared, named region, allows static link plugins to share information)

Allocates its shared memory global region, so if this library is built statically and referenced in multiple plugins ConfigScript can share the same symbol tables. This also provides sharing between C++ and C. 
A macro to specify the call type of schedule routines. This can be changed in most projects without affect, it comes into play if plugins built by different compilers are used, __cdecl is most standard. 
Not sure where this is referenced, this the core routine itself is scheduled with this symbol to the compiler if appropriate. 
A definition for how to declare these functions. if the source itself is comipling these are _export, otherwise external things linking here are _import. 
Routines are scheduled at this priority when the PRELOAD function is used. 
global_init_preload_priority-1 is used by sharemem.. memory needs init before it can register itself 
image_preload MUST be after Namespce preload (anything that uses RegisterAndCreateGlobal) should init this before vidlib (which needs image?) 
This is used once in deadstart_prog.c which is used to invoke startups when the program finishes loading. 
need to open the queues and threads before the service server can begin... 
Level which message core service initializes. During startup message services can register themselves also; but not before this priority level. 
Level which names initializes. Names is the process registration code. It has a common shared global registered.
procreg; aka names.c 
OS A[bstraction] L[ayer] O[n] T[op] - system lib 
This is the most basic way to define some code to run initialization before main.
Defines some code to run at program shutdown time. Allows specification of a priority. Higher priorities are run first. 
Defines some code to run at program inialization time. Allows specification of a priority. Lower priorities run first. (default is 69). 
Initialization level where PSI registers its builtin controls. 
This is the core atexit. It dispatches all other exit routines. This is defined for internal use only... 
this is just a global space initializer (shared, named region, allows static link plugins to share information) 
Level at which logging is initialized. Nothing under this should be doing logging, if it does, the behavior is not as well defined. 
Level at which the video render library performs its initialization; RegisterClass() level code. 
Created with a commercial version of Doc-O-Matic. In order to make this message disappear you need to register this software. If you have problems registering this software please contact us at
Copyright (c) 2000+. All rights reserved.
What do you think about this topic? Send feedback!