Changeset 1484:751cc39c852f


Ignore:
Timestamp:
08/29/10 12:44:24 (18 months ago)
Author:
niam
Branch:
default
Message:

[pc::execution::workqueue] properly handle exceptions in constructor

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sources/src/pcExecutionWorkqueue.cc

    r1482 r1484  
    4141#include <libdodo/pcSyncThread.h> 
    4242#include <libdodo/pcNotificationThread.h> 
     43#include <libdodo/exceptionBasic.h> 
    4344#include <libdodo/pcSyncStack.h> 
    4445#include <libdodo/types.h> 
     
    7778                                     minThreads(minThreads), 
    7879                                     minIdleTime(minIdleTime), 
    79                                      tasksProtector(new pc::sync::thread), 
    80                                      threadsProtector(new pc::sync::thread), 
    81                                      notification(new pc::notification::thread(*tasksProtector)), 
     80                                     tasksProtector(NULL), 
     81                                     threadsProtector(NULL), 
     82                                     notification(NULL), 
    8283                                     closing(false) 
    8384{ 
    84     if (maxThreads < minThreads) 
    85         maxThreads = minThreads; 
    86  
    87     thread *t; 
    88     for (unsigned int i=0; i<minThreads; ++i) { 
    89         t = new thread((routine)workqueue::worker, this, ON_DESTRUCTION_STOP); 
    90         inactive.push_back(t); 
    91         t->run(); 
     85    dodo_try { 
     86        tasksProtector = new pc::sync::thread; 
     87        threadsProtector = new pc::sync::thread; 
     88        notification = new pc::notification::thread(*tasksProtector); 
     89 
     90        if (maxThreads < minThreads) 
     91            maxThreads = minThreads; 
     92 
     93        thread *t; 
     94        for (unsigned int i=0; i<minThreads; ++i) { 
     95            t = new thread((routine)workqueue::worker, this, ON_DESTRUCTION_STOP); 
     96            inactive.push_back(t); 
     97            t->run(); 
     98        } 
     99    } dodo_catch (exception::basic *e UNUSED) { 
     100        delete notification; 
     101        delete tasksProtector; 
     102        delete threadsProtector; 
     103 
     104        dodo_rethrow; 
    92105    } 
    93106} 
Note: See TracChangeset for help on using the changeset viewer.