Changeset 1471:b85ecf59f9ab


Ignore:
Timestamp:
08/26/10 05:59:51 (18 months ago)
Author:
niam
Branch:
default
Message:

[lib] finished non-c++ exception integration

Location:
sources/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • sources/src/pcExecutionProcess.cc

    r1464 r1471  
    115115process::process(const dodo::string &module, 
    116116                 void             *data, 
    117                  void             *toInit) 
    118 /* FIXME */ 
    119 /* dodo_try */ : job(TYPE_PROCESS), 
    120       handle(NULL) 
    121 { 
    122     handle = new __process__; 
    123  
     117                 void             *toInit) : job(TYPE_PROCESS), 
     118                                             handle(new __process__) 
     119{ 
    124120    handle->data = data; 
    125121 
     
    129125    handle->handle = dlopen(module.data(), RTLD_LAZY); 
    130126#endif 
    131     if (handle->handle == NULL) 
     127    if (handle->handle == NULL) { 
     128        delete handle; 
     129 
    132130        dodo_throw exception::basic(exception::MODULE_PCEXECUTIONPROCESS, PROCESSEX_CONSTRUCTOR, exception::ERRNO_DYNLOAD, 0, dlerror(), __LINE__, __FILE__); 
     131    } 
    133132 
    134133    initModule init = (initModule)dlsym(handle->handle, "initPcExecutionProcessModule"); 
    135     if (init == NULL) 
     134    if (init == NULL) { 
     135        dlclose(handle->handle); 
     136        delete handle; 
     137 
    136138        dodo_throw exception::basic(exception::MODULE_PCEXECUTIONPROCESS, PROCESSEX_CONSTRUCTOR, exception::ERRNO_DYNLOAD, 0, dlerror(), __LINE__, __FILE__); 
     139    } 
    137140 
    138141    __module__ m = init(toInit); 
    139142 
    140143    void *f = dlsym(handle->handle, m.hook); 
    141     if (f == NULL) 
     144    if (f == NULL) { 
     145        dlclose(handle->handle); 
     146        delete handle; 
     147 
    142148        dodo_throw exception::basic(exception::MODULE_PCEXECUTIONPROCESS, PROCESSEX_CONSTRUCTOR, exception::ERRNO_DYNLOAD, 0, dlerror(), __LINE__, __FILE__); 
     149    } 
    143150 
    144151    handle->action = m.action; 
    145152    handle->func = f; 
    146153    memcpy(handle->cookie, m.cookie, 32); 
    147 } /* dodo_catch (exception::basic *e UNUSED) { */ 
    148 /*     if (handle) { */ 
    149 /*         if (handle->handle) */ 
    150 /*             dlclose(handle->handle); */ 
    151  
    152 /*         delete handle; */ 
    153 /*     } */ 
    154 /* } */ 
     154} 
    155155#endif 
    156156 
  • sources/src/pcExecutionScheduler.cc

    r1464 r1471  
    211211//------------------------------------------------------------------- 
    212212 
    213 scheduler::scheduler() 
    214     /* FIXME */ 
    215 /* dodo_try */ : counter(0), 
     213scheduler::scheduler() : counter(0), 
    216214      keeper(NULL), 
    217215      manager(NULL) 
    218  { 
    219      keeper = new pc::sync::thread; 
    220      manager = new __manager__; 
    221  
    222 #ifdef PTHREAD_EXT 
    223      errno = pthread_create(&manager->thread, NULL, __manager__::manager, this); 
    224      if (errno != 0) 
    225          dodo_throw exception::basic(exception::MODULE_PCEXECUTIONSCHEDULER, SCHEDULEREX_CONSTRUCTOR, exception::ERRNO_ERRNO, errno, strerror(errno), __LINE__, __FILE__); 
    226 #endif 
    227  }/*  dodo_catch (exception::basic *e UNUSED) { */ 
    228  /*    delete manager; */ 
    229  /*    delete keeper; */ 
    230  /* } */ 
    231  
     216{ 
     217    dodo_try { 
     218        keeper = new pc::sync::thread; 
     219        manager = new __manager__; 
     220    } dodo_catch (exception::basic *e UNUSED) { 
     221        delete manager; 
     222        delete keeper; 
     223 
     224        dodo_rethrow; 
     225    } 
     226 
     227#ifdef PTHREAD_EXT 
     228    errno = pthread_create(&manager->thread, NULL, __manager__::manager, this); 
     229    if (errno != 0) 
     230        dodo_throw exception::basic(exception::MODULE_PCEXECUTIONSCHEDULER, SCHEDULEREX_CONSTRUCTOR, exception::ERRNO_ERRNO, errno, strerror(errno), __LINE__, __FILE__); 
     231#endif 
     232} 
    232233//------------------------------------------------------------------- 
    233234 
  • sources/src/pcExecutionThread.cc

    r1468 r1471  
    148148               short         action, 
    149149               bool          detached, 
    150                unsigned long stackSize) 
    151     /* FIXME */ 
    152 /* dodo_try */ : job(TYPE_THREAD), 
    153       handle(NULL) 
    154     { 
    155         handle = new __thread__; 
    156  
    157 #ifdef PTHREAD_EXT 
    158         pthread_attr_init(&handle->attr); 
    159 #endif 
    160  
    161         handle->detached = detached; 
    162         handle->data = data; 
    163         handle->func = (void *)func; 
    164         handle->action = action; 
    165  
    166 #ifdef DL_EXT 
    167         handle->handle = NULL; 
    168 #endif 
    169  
    170 #ifdef PTHREAD_EXT 
    171         if (detached) 
    172             pthread_attr_setdetachstate(&handle->attr, PTHREAD_CREATE_DETACHED); 
    173         else 
    174             pthread_attr_setdetachstate(&handle->attr, PTHREAD_CREATE_JOINABLE); 
    175  
    176         errno = pthread_attr_setstacksize(&handle->attr, stackSize); 
    177         if (errno != 0) 
    178             dodo_throw exception::basic(exception::MODULE_PCEXECUTIONTHREAD, THREADEX_CONSTRUCTOR, exception::ERRNO_ERRNO, errno, strerror(errno), __LINE__, __FILE__); 
    179 #endif 
    180  
    181 #ifdef PTHREAD_EXT 
     150               unsigned long stackSize) : job(TYPE_THREAD), 
     151                                          handle(new __thread__) 
     152{ 
     153    handle->detached = detached; 
     154    handle->data = data; 
     155    handle->func = (void *)func; 
     156    handle->action = action; 
     157#ifdef DL_EXT 
     158    handle->handle = NULL; 
     159#endif 
     160 
     161#ifdef PTHREAD_EXT 
     162    pthread_attr_init(&handle->attr); 
     163 
     164    if (detached) 
     165        pthread_attr_setdetachstate(&handle->attr, PTHREAD_CREATE_DETACHED); 
     166    else 
     167        pthread_attr_setdetachstate(&handle->attr, PTHREAD_CREATE_JOINABLE); 
     168 
     169    errno = pthread_attr_setstacksize(&handle->attr, stackSize); 
     170    if (errno != 0) { 
    182171        pthread_attr_destroy(&handle->attr); 
    183 #endif 
    184     }/*  dodo_catch (exception::basic *e UNUSED) { */ 
    185 /*         if (handle) { */ 
    186 /* #ifdef PTHREAD_EXT */ 
    187 /*             pthread_attr_destroy(&handle->attr); */ 
    188 /* #endif */ 
    189 /*             delete handle; */ 
    190 /*         } */ 
    191 /*     } */ 
     172        delete handle; 
     173 
     174        dodo_throw exception::basic(exception::MODULE_PCEXECUTIONTHREAD, THREADEX_CONSTRUCTOR, exception::ERRNO_ERRNO, errno, strerror(errno), __LINE__, __FILE__); 
     175    } 
     176#endif 
     177} 
    192178 
    193179#ifdef DL_EXT 
    194180thread::thread(const dodo::string &module, 
    195181               void             *data, 
    196                void             *toInit) 
    197     /* FIXME */ 
    198 /* dodo_try */ : job(TYPE_THREAD), 
    199       handle(NULL) 
    200     { 
    201         handle = new __thread__; 
    202  
    203         handle->data = data; 
     182               void             *toInit) : job(TYPE_THREAD), 
     183                                           handle(new __thread__) 
     184{ 
     185    handle->data = data; 
    204186 
    205187#ifdef DL_FAST 
    206         handle->handle = dlopen(module.data(), RTLD_LAZY | RTLD_NODELETE); 
     188    handle->handle = dlopen(module.data(), RTLD_LAZY | RTLD_NODELETE); 
    207189#else 
    208         handle->handle = dlopen(module.data(), RTLD_LAZY); 
    209 #endif 
    210         if (handle->handle == NULL) 
    211             dodo_throw exception::basic(exception::MODULE_PCEXECUTIONTHREAD, THREADEX_CONSTRUCTOR, exception::ERRNO_DYNLOAD, 0, dlerror(), __LINE__, __FILE__); 
    212  
    213         initModule init = (initModule)dlsym(handle->handle, "initPcExecutionThreadModule"); 
    214         if (init == NULL) 
    215             dodo_throw exception::basic(exception::MODULE_PCEXECUTIONTHREAD, THREADEX_CONSTRUCTOR, exception::ERRNO_DYNLOAD, 0, dlerror(), __LINE__, __FILE__); 
    216  
    217         __module__ m = init(toInit); 
    218  
    219         void *f = dlsym(handle->handle, m.hook); 
    220         if (f == NULL) 
    221             dodo_throw exception::basic(exception::MODULE_PCEXECUTIONTHREAD, THREADEX_CONSTRUCTOR, exception::ERRNO_DYNLOAD, 0, dlerror(), __LINE__, __FILE__); 
    222  
    223         if (m.detached) 
    224             pthread_attr_setdetachstate(&handle->attr, PTHREAD_CREATE_DETACHED); 
    225         else 
    226             pthread_attr_setdetachstate(&handle->attr, PTHREAD_CREATE_JOINABLE); 
    227  
    228         errno = pthread_attr_setstacksize(&handle->attr, m.stackSize); 
    229         if (errno != 0) 
    230             dodo_throw exception::basic(exception::MODULE_PCEXECUTIONTHREAD, THREADEX_CONSTRUCTOR, exception::ERRNO_ERRNO, errno, strerror(errno), __LINE__, __FILE__); 
    231  
    232         handle->detached = m.detached; 
    233         handle->action = m.action; 
    234         handle->func = f; 
    235         memcpy(handle->cookie, m.cookie, 32); 
    236     } /* dodo_catch (exception::basic *e UNUSED) { */ 
    237 /*         if (handle) { */ 
    238 /*             if (handle->handle) */ 
    239 /*                 dlclose(handle->handle); */ 
    240  
    241 /* #ifdef PTHREAD_EXT */ 
    242 /*             pthread_attr_destroy(&handle->attr); */ 
    243 /* #endif */ 
    244  
    245 /*             delete handle; */ 
    246 /*         } */ 
    247 /*     } */ 
     190    handle->handle = dlopen(module.data(), RTLD_LAZY); 
     191#endif 
     192    if (handle->handle == NULL) { 
     193        delete handle; 
     194 
     195        dodo_throw exception::basic(exception::MODULE_PCEXECUTIONTHREAD, THREADEX_CONSTRUCTOR, exception::ERRNO_DYNLOAD, 0, dlerror(), __LINE__, __FILE__); 
     196    } 
     197 
     198    initModule init = (initModule)dlsym(handle->handle, "initPcExecutionThreadModule"); 
     199    if (init == NULL) { 
     200        dlclose(handle->handle); 
     201        delete handle; 
     202 
     203        dodo_throw exception::basic(exception::MODULE_PCEXECUTIONTHREAD, THREADEX_CONSTRUCTOR, exception::ERRNO_DYNLOAD, 0, dlerror(), __LINE__, __FILE__); 
     204    } 
     205 
     206    __module__ m = init(toInit); 
     207 
     208    void *f = dlsym(handle->handle, m.hook); 
     209    if (f == NULL) { 
     210        dlclose(handle->handle); 
     211        delete handle; 
     212 
     213        dodo_throw exception::basic(exception::MODULE_PCEXECUTIONTHREAD, THREADEX_CONSTRUCTOR, exception::ERRNO_DYNLOAD, 0, dlerror(), __LINE__, __FILE__); 
     214    } 
     215 
     216#ifdef PTHREAD_EXT 
     217    pthread_attr_init(&handle->attr); 
     218 
     219    if (m.detached) 
     220        pthread_attr_setdetachstate(&handle->attr, PTHREAD_CREATE_DETACHED); 
     221    else 
     222        pthread_attr_setdetachstate(&handle->attr, PTHREAD_CREATE_JOINABLE); 
     223 
     224    errno = pthread_attr_setstacksize(&handle->attr, m.stackSize); 
     225    if (errno != 0) { 
     226        dlclose(handle->handle); 
     227        pthread_attr_destroy(&handle->attr); 
     228        delete handle; 
     229 
     230        dodo_throw exception::basic(exception::MODULE_PCEXECUTIONTHREAD, THREADEX_CONSTRUCTOR, exception::ERRNO_ERRNO, errno, strerror(errno), __LINE__, __FILE__); 
     231    } 
     232#endif 
     233 
     234    handle->detached = m.detached; 
     235    handle->action = m.action; 
     236    handle->func = f; 
     237    memcpy(handle->cookie, m.cookie, 32); 
     238} 
    248239#endif 
    249240 
Note: See TracChangeset for help on using the changeset viewer.