Changeset 1400:aa7829bd0b9c
- Timestamp:
- 11/07/09 21:50:59 (2 years ago)
- Branch:
- default
- Location:
- src
- Files:
-
- 4 edited
-
examples/pc_thread/test.cc (modified) (2 diffs)
-
include/libdodo/exceptionBasic.h (modified) (2 diffs)
-
include/libdodo/pcExecutionThread.h (modified) (2 diffs)
-
src/pcExecutionThread.cc (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/examples/pc_thread/test.cc
r1397 r1400 31 31 cout.flush(); 32 32 } catch (dodo::exception::basic &ex) { 33 cout << (dodoString)ex << ex.line << endl;33 cout << (dodoString)ex << "\t" << ex.line << "\t" << ex.file << endl; 34 34 } 35 36 // throwing exception 37 tools::os::os::setWorkingDir("./dir/"); 35 38 36 39 return 0; … … 66 69 manager.wait(); 67 70 71 for (int i = 0; i < amount; ++i) { 72 dodo::exception::basic *ex = manager.job(pos[i])->exception(); 73 if (ex) { 74 cout << "Thread " << i << ":\t" << (dodoString)*ex << "\t" << ex->line << "\t" << ex->file << endl; 75 } 76 } 77 68 78 delete data; 69 79 } catch (dodo::exception::basic &ex) { 70 cout << (dodoString)ex << endl;80 cout << (dodoString)ex << "\t" << ex.line << "\t" << ex.file << endl; 71 81 } 72 82 -
src/include/libdodo/exceptionBasic.h
r1386 r1400 143 143 public: 144 144 145 #ifdef DL_EXT146 /**147 * @struct __module__148 * @brief is returned from initModule in the library149 */150 struct __module__ {151 char name[64]; ///< name of the library152 char discription[256]; ///< discription of the library153 char hook[64]; ///< name of the function in module that will be as a hook154 char cookie[32]; ///< cookie that would be passed to deinitModule155 bool modules[MODULE_ENUMSIZE]; ///< for what modules handler should be set, @see exception::moduleEnum156 };157 158 /**159 * @typedef initModule160 * @brief defines type of init function for library161 * @param data defines user data162 * @note name in the library must be initExceptionBasicModule163 */164 typedef __module__ (*initModule)(void *data);165 166 /**167 * @typedef deinitModule168 * @brief defines type of deinit function for library169 * @param cookie defines cookie data returned from initModule170 * @note name in the library must be deinitExceptionBasicModule171 */172 typedef void (*deinitModule)(char cookie[32]);173 #endif174 175 /**176 * @typedef handler177 * @brief defines type of hook function178 * @param module defines module where exception occured, @see exception::moduleEnum179 * @param ex defines pointer to basic object with exception information180 * @param data defines user data181 */182 typedef void (*handler)(int module, basic *ex, void *data);183 184 145 /** 185 146 * constructor … … 207 168 ~basic() throw (); 208 169 170 #ifdef DL_EXT 171 /** 172 * @struct __module__ 173 * @brief is returned from initModule in the library 174 */ 175 struct __module__ { 176 char name[64]; ///< name of the library 177 char discription[256]; ///< discription of the library 178 char hook[64]; ///< name of the function in module that will be as a hook 179 char cookie[32]; ///< cookie that would be passed to deinitModule 180 bool modules[MODULE_ENUMSIZE]; ///< for what modules handler should be set, @see exception::moduleEnum 181 }; 182 183 /** 184 * @typedef initModule 185 * @brief defines type of init function for library 186 * @param data defines user data 187 * @note name in the library must be initExceptionBasicModule 188 */ 189 typedef __module__ (*initModule)(void *data); 190 191 /** 192 * @typedef deinitModule 193 * @brief defines type of deinit function for library 194 * @param cookie defines cookie data returned from initModule 195 * @note name in the library must be deinitExceptionBasicModule 196 */ 197 typedef void (*deinitModule)(char cookie[32]); 198 #endif 199 200 /** 201 * @typedef handler 202 * @brief defines type of hook function 203 * @param module defines module where exception occured, @see exception::moduleEnum 204 * @param ex defines pointer to basic object with exception information 205 * @param data defines user data 206 */ 207 typedef void (*handler)(int module, basic *ex, void *data); 208 209 209 /** 210 210 * @return error string -
src/include/libdodo/pcExecutionThread.h
r1386 r1400 37 37 38 38 namespace dodo { 39 namespace exception { 40 class basic; 41 }; 42 39 43 namespace pc { 40 44 namespace execution { … … 105 109 virtual bool isRunning() const; 106 110 111 /** 112 * @return uncought exception thrown by thread routine 113 */ 114 virtual exception::basic *exception(); 115 107 116 #ifdef DL_EXT 108 117 /** -
src/src/pcExecutionThread.cc
r1386 r1400 41 41 42 42 namespace dodo { 43 namespace exception { 44 class basic; 45 }; 46 43 47 namespace pc { 44 48 namespace execution { … … 57 61 executed(false), 58 62 joined(false), 59 status(0) 63 status(0), 64 ex(NULL) 60 65 #ifdef DL_EXT 61 66 , … … 79 84 #endif 80 85 86 void *func; ///< function to execute 81 87 void *data; ///< thread data 88 82 89 bool executed; ///< true if thread is running 83 90 bool joined; ///< true if the thread was joined 84 91 int status; ///< thread exit status 85 92 bool detached; ///< true if thread is detached 86 void *func; ///< function to execute87 93 short action; ///< action on object destruction[@see onDestructionEnum] 94 95 exception::basic *ex; ///< uncought exception thrown by thread routine 96 88 97 #ifdef DL_EXT 89 98 void *handle; ///< handle to library … … 100 109 #include <libdodo/pcExecutionThreadEx.h> 101 110 #include <libdodo/types.h> 111 #include <libdodo/exceptionBasic.h> 102 112 103 113 using namespace dodo::pc::execution; … … 109 119 __thread__ *ti = (__thread__ *)data; 110 120 111 ti->status = ((execution::routine)ti->func)(ti->data); 121 try { 122 delete ti->ex; 123 ti->ex = NULL; 124 125 ti->status = ((execution::routine)ti->func)(ti->data); 126 } catch (exception::basic &ex) { 127 ti->ex = new exception::basic(ex); 128 ti->status = 0; 129 } 112 130 113 131 return NULL; … … 283 301 } 284 302 303 delete handle->ex; 304 285 305 delete handle; 286 306 } … … 408 428 409 429 //------------------------------------------------------------------- 430 431 dodo::exception::basic * 432 thread::exception() 433 { 434 return handle->ex; 435 } 436 437 //-------------------------------------------------------------------
Note: See TracChangeset
for help on using the changeset viewer.
