Mercurial > projects > mde
diff mde/setup/Init.d @ 91:4d5d53e4f881
Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Some debugging improvements.
When multiple .mtt files are read for merging, files with invalid headers are ignored and no error is thrown so long as at least one file os valid.
author | Diggory Hardy <diggory.hardy@gmail.com> |
---|---|
date | Thu, 16 Oct 2008 17:43:48 +0100 |
parents | 97e6dce08037 |
children | 9520cc0448e5 |
line wrap: on
line diff
--- a/mde/setup/Init.d Wed Oct 01 23:37:51 2008 +0100 +++ b/mde/setup/Init.d Thu Oct 16 17:43:48 2008 +0100 @@ -51,7 +51,7 @@ import tango.core.Thread; import tango.core.sync.Condition; import tango.core.Exception; -import tango.util.container.CircularList; +import tango.util.container.LinkedList; //import tango.stdc.stringz : fromStringz; import tango.io.Console; // for printing command-line usage @@ -233,7 +233,7 @@ // run init stages or cleanup if startup is false private static void runStages(bool startup) () { - CircularList!(InitStage*) toRun = new CircularList!(InitStage*); + auto toRun = new LinkedList!(InitStage*); foreach (v; stages) { // Filter only stages with the relevant delegate. It is not checked later that the // delegate exists! @@ -255,7 +255,6 @@ } } } - auto toRunIt = toRun.iterator; // Counts number of active threads, and before threads are started is number to use: size_t numWorking = (toRun.size < miscOpts.maxThreads) ? toRun.size : miscOpts.maxThreads; enum STATE { WORKING = 0, DONE = 1, ABORT = 2 } @@ -292,13 +291,10 @@ getStage: while (true) { - static if (false) // An addition to CircularList to allow continuous circular iteration; not yet in tango. - toRunIt.start; // start circling from here - else - toRunIt = toRun.iterator; // new iterator + auto toRunIt = toRun.iterator; // iterates toRun itStages: - while (toRunIt.next (stage)) { // get next element of toRun - debug logger.trace ("Iterating: {}", stage); + while (toRunIt.next (stage)) { // get next element of toRun + debug assert (stage !is null, "stage is null"); static if (startup) { foreach (d; stage.depends) if (stages[d].state != StageState.ACTIVE) @@ -332,19 +328,21 @@ // Do a job: try { // FIXME - old stage start&finish trace messages - we don't have a name! - debug logger.trace ("InitStage {}: starting", stage); - static if (startup) - stage.state = (*stage).init(); // init is a property of a pointer (oh no!) - else + static if (startup) { + debug logger.trace ("InitStage {}: starting init", stage.name); + stage.state = (*stage).init(); // init is a property of a pointer (oh no!) + } else { + debug logger.trace ("InitStage {}: starting cleanup", stage.name); stage.state = stage.cleanup(); - debug logger.trace ("InitStage {}: completed; state: {}", stage, stage.state); + } + debug logger.trace ("InitStage {}: completed; state: {}", stage.name, stage.state); } catch (InitStageException e) { - debug logger.trace ("InitStage {}: failed", stage); + debug logger.trace ("InitStage {}: failed: "~e.msg, stage.name); stage.state = e.state; doneInit = STATE.ABORT; break threadLoop; } catch (Exception e) { - debug logger.trace ("InitStage {}: failed", stage); + debug logger.trace ("InitStage {}: failed: "~e.msg, stage.name); doneInit = STATE.ABORT; break threadLoop; } @@ -377,7 +375,7 @@ if (toRun.size) foreach (stage; toRun) - logger.warn ("InitStage {}: was not run due to unmet dependencies", stage); + logger.warn ("InitStage {}: was not run due to unmet dependencies", stage.name); } private static { @@ -445,10 +443,11 @@ foreach (key,stage_p; stages) foreach (name; stage_p.depends) stages[name].rdepends ~= key; - auto realNumThreads = miscOpts.numThreads; - miscOpts.set!(int)("numThreads", 4); // force 4 threads for unittest + auto realMaxThreads = miscOpts.maxThreads; + miscOpts.set!(int)("maxThreads", 4); // force up to 4 threads for unittest - + logger.level(Logger.Info); // hide a lot of trace messages + logger.info ("You should see some warning messages starting \"InitStage\":"); // Run the above. runStages!(true); assert (init1); @@ -485,7 +484,7 @@ assert (stages[toStageName("stg3")].state == cast(StageState)7); // set by the exception stages = realInit; // restore the real init stages - miscOpts.set!(int)("numThreads", realNumThreads); + miscOpts.set!(int)("maxThreads", realMaxThreads); logger.info ("Unittest complete."); } }