diff mde/scheduler/Init.d @ 21:a60cbb7359dd

Window settings now come from options, and may use OpenGL (enabled/disabled at compile time). committer: Diggory Hardy <diggory.hardy@gmail.com>
author Diggory Hardy <diggory.hardy@gmail.com>
date Mon, 24 Mar 2008 17:53:28 +0000
parents 838577503598
children 32eff0e01c05
line wrap: on
line diff
--- a/mde/scheduler/Init.d	Sat Mar 22 16:22:59 2008 +0000
+++ b/mde/scheduler/Init.d	Mon Mar 24 17:53:28 2008 +0000
@@ -84,9 +84,6 @@
 {
 }
 
-// Global instance, since called init functions need to interact:
-scope Init init;
-
 /**
  * Init class
  *
@@ -138,22 +135,26 @@
         * Current method is to try using threads, and on failure assume no threads were actually
         * created and run functions in a non-threaded manner. */
         
-        try {   // init2
-            cleanupStages ~= &cleanup2; // add appropriate cleanup stage
-            
+        // init2
+        cleanupStages ~= &cleanup2;     // add appropriate cleanup stage
+        try {
+            logger.trace ("Init: init2");
             if (runStageThreaded (init2)) runStageForward (init2);
         }
         catch (InitStageException) {    // This init stage failed.
+            logger.trace ("Init: init2 failed");
             runCleanupStages();
             throw new InitException ("Initialisation failed during stage init2");
         }
         
-        try {   // init4
-            cleanupStages ~= &cleanup4; // add appropriate cleanup stage
-            
+        // init4
+        cleanupStages ~= &cleanup4;     // add appropriate cleanup stage
+        try {
+            logger.trace ("Init: init4");
             if (runStageThreaded (init4)) runStageForward (init4);
         }
         catch (InitStageException) {    // This init stage failed.
+            logger.trace ("Init: init4 failed");
             runCleanupStages();
             throw new InitException ("Initialisation failed during stage init4");
         }
@@ -181,24 +182,25 @@
     private static {
         /* The following three functions, runStage*, each run all functions in a stage in some order,
         * catching any exceptions thrown by the functions (although this isn't guaranteed for threads),
-        * and throw an InitStageException on failure. */
+        * and throw an InitStageException on initFailure. */
     
         const UFE = "Unhandled exception from Init function:";
         /* Runs all functions consecutively, first-to-last.
         * If any function fails, halts immediately. */
         void runStageForward (InitStage s) {
             foreach (func; s.funcs) {
-                if (s.failure) break;
+                if (initFailure) break;
                 try {
                     func();
                 } catch (Exception e) {
                     logger.fatal (UFE);
                     logger.fatal (e.msg);
                 
-                    s.setFailure();
+                    setInitFailure();
                 }
             }
-            if (s.failure) throw new InitStageException;    // Problem running; abort and cleanup from here.
+            
+            if (initFailure) throw new InitStageException;    // Problem running; abort and cleanup from here.
         }
         /* Runs all functions consecutively, last-to-first.
         * If any function fails, continue until all have been run. */
@@ -210,10 +212,10 @@
                     logger.fatal (UFE);
                     logger.fatal (e.msg);
                 
-                    s.setFailure();
+                    setInitFailure();
                 }
             }
-            if (s.failure) throw new InitStageException;    // Problem running; abort and cleanup from here.
+            if (initFailure) throw new InitStageException;    // Problem running; abort and cleanup from here.
         }
         /* Tries running functions in a threaded way. Returns false if successful, true if not but
         * functions should be run without threads. */
@@ -247,11 +249,11 @@
                     logger.fatal ("Unhandled exception from Init function:");
                     logger.fatal (e.msg);
                 
-                    s.setFailure ();        // abort (but join other threads first)
+                    setInitFailure ();        // abort (but join other threads first)
                 }
             }
-        
-            if (s.failure) throw new InitStageException;    // Problem running; abort and cleanup from here.
+            
+            if (initFailure) throw new InitStageException;    // Problem running; abort and cleanup from here.
             return false;                   // Done successfully
         }
     }