Mercurial > projects > mde
comparison mde/setup/Init.d @ 86:79d816b3e2d2
New InitStage system, Screen & Screen.Drawable, separate testing and guiDemo binaries.
This (and the previous) commit are the result of several quite significant changes to mde. All the unittests run, but it hasn't had a huge amount of testing so don't be surprised if bugs show up.
author | Diggory Hardy <diggory.hardy@gmail.com> |
---|---|
date | Fri, 12 Sep 2008 17:36:14 +0100 |
parents | 56c0ddd90193 |
children | 01f4f5f1acc9 |
comparison
equal
deleted
inserted
replaced
85:56c0ddd90193 | 86:79d816b3e2d2 |
---|---|
255 else | 255 else |
256 v.state = StageState.INACTIVE; | 256 v.state = StageState.INACTIVE; |
257 } | 257 } |
258 } | 258 } |
259 } | 259 } |
260 debug logger.trace ("Added {} init/cleanup stages", toRun.size); | |
261 int numWorking = miscOpts.numThreads; | 260 int numWorking = miscOpts.numThreads; |
262 bool abortInit = false; | 261 bool abortInit = false; |
263 Mutex toRunM = new Mutex; // synchronization on toRun, numWorking | 262 Mutex toRunM = new Mutex; // synchronization on toRun, numWorking |
264 Condition toRunC = new Condition(toRunM); // used by threads waiting for remaining stages' dependencies to be met | 263 Condition toRunC = new Condition(toRunM); // used by threads waiting for remaining stages' dependencies to be met |
265 | 264 |
273 * if not found: | 272 * if not found: |
274 * if any other threads are working, wait (dependencies may not be met yet) | 273 * if any other threads are working, wait (dependencies may not be met yet) |
275 * if no other threads are working, notify waiting threads and terminate (finished) | 274 * if no other threads are working, notify waiting threads and terminate (finished) |
276 * When notified, threads start at 1. */ | 275 * When notified, threads start at 1. */ |
277 void initThreadFct () { | 276 void initThreadFct () { |
278 debug logger.trace ("initThreadFct: starting"); | |
279 try { // created as a thread - must not throw exceptions | 277 try { // created as a thread - must not throw exceptions |
280 InitStage* stage; | 278 InitStage* stage; |
281 | 279 |
282 threadLoop: while (true) { // thread loops until a problem occurs or nothing else can be done | 280 threadLoop: while (true) { // thread loops until a problem occurs or nothing else can be done |
283 // Look for a job: | 281 // Look for a job: |
344 } catch (Exception e) { | 342 } catch (Exception e) { |
345 logger.fatal ("Exception in initThreadFct: "~e.msg); | 343 logger.fatal ("Exception in initThreadFct: "~e.msg); |
346 abortInit = true; | 344 abortInit = true; |
347 } | 345 } |
348 toRunC.notifyAll(); // Most likely if we're exiting, we should make sure others aren't waiting. | 346 toRunC.notifyAll(); // Most likely if we're exiting, we should make sure others aren't waiting. |
349 debug logger.trace ("initThreadFct: returning"); | |
350 return; | 347 return; |
351 } | 348 } |
352 | 349 |
353 // Start miscOpts.NumThreads - 1 threads: | 350 // Start miscOpts.NumThreads - 1 threads: |
354 try { | 351 try { |
394 --help, -h Print this message.`).newline; | 391 --help, -h Print this message.`).newline; |
395 } | 392 } |
396 } | 393 } |
397 | 394 |
398 debug (mdeUnitTest) unittest { | 395 debug (mdeUnitTest) unittest { |
399 logger.trace ("Starting unittest"); | |
400 | |
401 auto realInit = stages; // backup the real init stages | 396 auto realInit = stages; // backup the real init stages |
402 stages = new typeof(stages); // an empty test-bed | 397 stages = new typeof(stages); // an empty test-bed |
403 | 398 |
404 bool init1, init2, init3 = true; | 399 bool init1, init2, init3 = true; |
405 bool failed = false; // set if anything goes wrong | 400 bool failed = false; // set if anything goes wrong |