Changeset 1471:b85ecf59f9ab
- Timestamp:
- 08/26/10 05:59:51 (18 months ago)
- Branch:
- default
- Location:
- sources/src
- Files:
-
- 3 edited
-
pcExecutionProcess.cc (modified) (2 diffs)
-
pcExecutionScheduler.cc (modified) (1 diff)
-
pcExecutionThread.cc (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
sources/src/pcExecutionProcess.cc
r1464 r1471 115 115 process::process(const dodo::string &module, 116 116 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 { 124 120 handle->data = data; 125 121 … … 129 125 handle->handle = dlopen(module.data(), RTLD_LAZY); 130 126 #endif 131 if (handle->handle == NULL) 127 if (handle->handle == NULL) { 128 delete handle; 129 132 130 dodo_throw exception::basic(exception::MODULE_PCEXECUTIONPROCESS, PROCESSEX_CONSTRUCTOR, exception::ERRNO_DYNLOAD, 0, dlerror(), __LINE__, __FILE__); 131 } 133 132 134 133 initModule init = (initModule)dlsym(handle->handle, "initPcExecutionProcessModule"); 135 if (init == NULL) 134 if (init == NULL) { 135 dlclose(handle->handle); 136 delete handle; 137 136 138 dodo_throw exception::basic(exception::MODULE_PCEXECUTIONPROCESS, PROCESSEX_CONSTRUCTOR, exception::ERRNO_DYNLOAD, 0, dlerror(), __LINE__, __FILE__); 139 } 137 140 138 141 __module__ m = init(toInit); 139 142 140 143 void *f = dlsym(handle->handle, m.hook); 141 if (f == NULL) 144 if (f == NULL) { 145 dlclose(handle->handle); 146 delete handle; 147 142 148 dodo_throw exception::basic(exception::MODULE_PCEXECUTIONPROCESS, PROCESSEX_CONSTRUCTOR, exception::ERRNO_DYNLOAD, 0, dlerror(), __LINE__, __FILE__); 149 } 143 150 144 151 handle->action = m.action; 145 152 handle->func = f; 146 153 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 } 155 155 #endif 156 156 -
sources/src/pcExecutionScheduler.cc
r1464 r1471 211 211 //------------------------------------------------------------------- 212 212 213 scheduler::scheduler() 214 /* FIXME */ 215 /* dodo_try */ : counter(0), 213 scheduler::scheduler() : counter(0), 216 214 keeper(NULL), 217 215 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 } 232 233 //------------------------------------------------------------------- 233 234 -
sources/src/pcExecutionThread.cc
r1468 r1471 148 148 short action, 149 149 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) { 182 171 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 } 192 178 193 179 #ifdef DL_EXT 194 180 thread::thread(const dodo::string &module, 195 181 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; 204 186 205 187 #ifdef DL_FAST 206 handle->handle = dlopen(module.data(), RTLD_LAZY | RTLD_NODELETE);188 handle->handle = dlopen(module.data(), RTLD_LAZY | RTLD_NODELETE); 207 189 #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 } 248 239 #endif 249 240
Note: See TracChangeset
for help on using the changeset viewer.
