Changeset 1410:a443cf659b82
- Timestamp:
- 11/08/09 09:50:50 (2 years ago)
- Branch:
- default
- Children:
- 1411:c4e7d7b15215, 1414:90d39a446bbc
- Location:
- sources
- Files:
-
- 8 edited
- 3 copied
-
examples/pc_job/test.cc (modified) (3 diffs)
-
include/libdodo/exceptionBasic.h (modified) (1 diff)
-
include/libdodo/pc.h (modified) (1 diff)
-
include/libdodo/pcExecutionManager.h (modified) (2 diffs)
-
include/libdodo/pcExecutionScheduler.h (copied) (copied from sources/include/libdodo/pcExecutionManager.h) (5 diffs)
-
include/libdodo/pcExecutionSchedulerEx.h (copied) (copied from sources/include/libdodo/pcExecutionManagerEx.h) (3 diffs)
-
include/libdodo/toolsOs.h (modified) (1 diff)
-
src/exceptionBasic.cc (modified) (6 diffs)
-
src/pcExecutionScheduler.cc (copied) (copied from sources/include/libdodo/pcExecutionManager.inline) (4 diffs)
-
src/pcExecutionThread.cc (modified) (1 diff)
-
src/pcSyncThread.cc (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
sources/examples/pc_job/test.cc
r1406 r1410 15 15 16 16 int 17 job (void *data)17 job0(void *data) 18 18 { 19 19 try { 20 cout << endl << (char *)data << ": " << tools::time::now() << endl; 21 cout.flush(); 20 cout << endl << (char *)data << ": " << tools::time::millinow() << endl; 21 } catch (dodo::exception::basic &ex) { 22 cout << (dodoString)ex << "\t" << ex.line << "\t" << ex.file << endl; 23 } 24 25 return 10; 26 } 27 28 int 29 job1(void *data) 30 { 31 try { 32 cout << endl << ">>" << (char *)data << ": " << tools::time::millinow() << endl; 22 33 23 34 tools::os::sleep(2); 24 35 25 cout << endl << (char *)data << ": " << tools::time::now() << endl; 26 cout.flush(); 36 cout << endl << "<<" << (char *)data << ": " << tools::time::millinow() << endl; 27 37 } catch (dodo::exception::basic &ex) { 28 38 cout << (dodoString)ex << "\t" << ex.line << "\t" << ex.file << endl; … … 39 49 const int amount = 10; 40 50 51 execution::thread periodic(::job0, (void *)"periodic", execution::ON_DESTRUCTION_STOP); 52 execution::thread oneshot0(::job0, (void *)"oneshot", execution::ON_DESTRUCTION_STOP); 53 execution::process oneshot1(::job0, (void *)"oneshot", execution::ON_DESTRUCTION_STOP); 54 execution::scheduler scheduler; 55 56 unsigned long pID = scheduler.schedule(&periodic, 1000, true); 57 scheduler.schedule(&oneshot0, 2000); 58 scheduler.schedule(&oneshot1, 3000); 59 41 60 execution::job *jobs[amount]; 42 61 … … 45 64 ids[i] = tools::string::lToString(i); 46 65 if (i % 2 == 0) 47 jobs[i] = new execution::thread(::job , (void *)ids[i].c_str(), execution::ON_DESTRUCTION_STOP);66 jobs[i] = new execution::thread(::job1, (void *)ids[i].c_str(), execution::ON_DESTRUCTION_STOP); 48 67 else 49 jobs[i] = new execution::process(::job , (void *)ids[i].c_str(), execution::ON_DESTRUCTION_STOP);68 jobs[i] = new execution::process(::job1, (void *)ids[i].c_str(), execution::ON_DESTRUCTION_STOP); 50 69 } 51 70 52 71 cout << "Launching jobs" << endl; 53 cout << tools::time::now() << endl; 54 cout.flush(); 72 cout << tools::time::millinow() << endl; 55 73 56 74 for (int i = 0; i < amount; ++i) 57 75 jobs[i]->run(); 76 77 cout << tools::time::millinow() << endl; 78 tools::os::sleep(2); 79 cout << tools::time::millinow() << endl; 80 scheduler.remove(pID); 81 pID = scheduler.schedule(&periodic, 100, true); 82 cout << tools::time::millinow() << endl; 83 tools::os::sleep(2); 84 scheduler.remove(pID); 85 cout << tools::time::millinow() << endl; 86 tools::os::sleep(2); 87 cout << tools::time::millinow() << endl; 58 88 59 89 for (int i = 0; i < amount; ++i) -
sources/include/libdodo/exceptionBasic.h
r1406 r1410 98 98 MODULE_IOEVENTMANAGER, 99 99 MODULE_PCEXECUTIONMANAGER, 100 MODULE_PCEXECUTIONSCHEDULER, 100 101 MODULE_PCEXECUTIONPROCESS, 101 102 MODULE_PCEXECUTIONTHREAD, -
sources/include/libdodo/pc.h
r1406 r1410 37 37 #include <libdodo/pcExecutionProcessEx.h> 38 38 #include <libdodo/pcExecutionManager.h> 39 #include <libdodo/pcExecutionScheduler.h> 40 #include <libdodo/pcExecutionSchedulerEx.h> 39 41 #include <libdodo/pcSyncDataObject.h> 40 42 #include <libdodo/pcSyncProcess.h> -
sources/include/libdodo/pcExecutionManager.h
r1406 r1410 34 34 35 35 #include <libdodo/types.h> 36 #include <libdodo/pcSyncStack.h>37 36 38 37 namespace dodo { 39 38 namespace pc { 39 namespace sync { 40 class protector; 41 }; 42 40 43 namespace execution { 41 44 /** … … 70 73 */ 71 74 void remove(unsigned long id, 72 bool terminate = false);75 bool terminate = false); 73 76 74 77 /** -
sources/include/libdodo/pcExecutionScheduler.h
r1406 r1410 1 1 /*************************************************************************** 2 * pcExecution Manager.h2 * pcExecutionScheduler.h 3 3 * 4 * Mon Mar 05 20075 * Copyright 200 7Ni@m4 * Sun Nov 08 2009 5 * Copyright 2009 Ni@m 6 6 * niam.niam@gmail.com 7 7 ****************************************************************************/ … … 28 28 */ 29 29 30 #ifndef _PCEXECUTION MANAGER_H_31 #define _PCEXECUTION MANAGER_H_ 130 #ifndef _PCEXECUTIONSCHEDULER_H_ 31 #define _PCEXECUTIONSCHEDULER_H_ 1 32 32 33 33 #include <libdodo/directives.h> 34 34 35 35 #include <libdodo/types.h> 36 #include <libdodo/pcSyncStack.h>37 36 38 37 namespace dodo { 39 38 namespace pc { 39 namespace sync { 40 class protector; 41 }; 42 43 struct __manager__; 44 40 45 namespace execution { 46 class job; 47 41 48 /** 42 * @class manager49 * @class scheduler 43 50 * @brief provides interface for jobs management 44 51 */ 45 template <typename T> 46 class manager { 52 class scheduler { 53 friend struct __manager__; 54 47 55 public: 48 56 … … 50 58 * constructor 51 59 */ 52 manager();60 scheduler(); 53 61 54 62 /** 55 63 * destructor 56 64 */ 57 ~ manager();65 ~scheduler(); 58 66 59 67 /** 60 * adda job68 * schedule a job 61 69 * @return job identificator 62 * @param job defines job for managing 70 * @param job defines job for scheduling 71 * @param timeout defines timeout of job scheduling in milliseconds 72 * @param repeat defines if job should be rescheduled again 63 73 */ 64 unsigned long add(const T &job); 74 unsigned long schedule(execution::job *job, 75 unsigned long timeout, 76 bool repeat = false); 65 77 66 78 /** … … 70 82 */ 71 83 void remove(unsigned long id, 72 bool terminate = false); 73 74 /** 75 * execute job 76 * @param id defines job identificator 77 */ 78 void run(unsigned long id); 79 80 /** 81 * stop job 82 * @param id defines job identificator 83 */ 84 void stop(unsigned long id); 85 86 /** 87 * stop all registered jobs 88 */ 89 void stop(); 90 91 /** 92 * wait for job termination 93 * @return status of the job 94 * @param id defines job identificator 95 */ 96 int wait(unsigned long id); 97 98 /** 99 * wait for all registered jobs termination 100 */ 101 void wait(); 102 103 /** 104 * @return true if job is running 105 * @param id defines job identificator 106 */ 107 bool isRunning(unsigned long id) const; 108 109 /** 110 * @return amount of running jobs 111 */ 112 unsigned long running() const; 113 114 /** 115 * @return list of jobs in object 116 */ 117 dodoList<unsigned long> jobs(); 118 119 /** 120 * @return job object 121 * @param id defines job identificator 122 */ 123 T *job(unsigned long id); 84 bool terminate = false); 124 85 125 86 protected: 126 87 127 dodoMap<unsigned long, T> handles; ///< managed jobs 88 struct __job__ { 89 execution::job *job; ///< job for scheduling 90 unsigned long timeout; ///< timeout for job scheduling 91 unsigned long ts; ///< timestamp of last time job was executed or added 92 bool repeat; ///< if the job is to be rescheduled 93 }; 94 95 dodoMap<unsigned long, __job__> handles; ///< managed jobs 128 96 129 97 unsigned long counter; ///< job id counter 130 98 131 99 sync::protector *keeper; ///< section locker 100 101 __manager__ *manager; ///< schedule manager handle 132 102 }; 133 103 }; … … 135 105 }; 136 106 137 #include <libdodo/pcExecutionManager.inline>138 139 107 #endif -
sources/include/libdodo/pcExecutionSchedulerEx.h
r1406 r1410 1 1 /*************************************************************************** 2 * pcExecution ManagerEx.h2 * pcExecutionSchedulerEx.h 3 3 * 4 * Wed Oct 0720094 * Sun Nov 08 2009 5 5 * Copyright 2009 Ni@m 6 6 * niam.niam@gmail.com … … 28 28 */ 29 29 30 #ifndef _PCEXECUTION MANAGEREX_H_31 #define _PCEXECUTION MANAGEREX_H_ 130 #ifndef _PCEXECUTIONSCHEDULEREX_H_ 31 #define _PCEXECUTIONSCHEDULEREX_H_ 1 32 32 33 33 #include <libdodo/directives.h> … … 39 39 namespace execution { 40 40 /** 41 * libdodo defined errors42 */43 enum managerExR {44 MANAGEREX_NOTFOUND,45 };46 47 /**48 * libdodo defined errors explanation49 */50 #define PCEXECUTIONMANAGEREX_NOTFOUND_STR "Job was not found"51 /**52 41 * ID of function where exception was thrown 53 42 */ 54 enum managerFunctionsID { 55 MANAGEREX_RUN, 56 MANAGEREX_WAIT, 57 MANAGEREX_STOP, 58 MANAGEREX_ISRUNNING, 59 MANAGEREX_JOB, 43 enum schedulerFunctionsID { 44 SCHEDULEREX___MANAGER__CONSTRUCTOR, 45 SCHEDULEREX_CONSTRUCTOR, 60 46 }; 61 47 }; -
sources/include/libdodo/toolsOs.h
r1406 r1410 125 125 */ 126 126 struct __usage__ { 127 long time; ///< processor time of execution in mil iseconds127 long time; ///< processor time of execution in milliseconds 128 128 long mem; ///< memory usage in bytes 129 129 }; -
sources/src/exceptionBasic.cc
r1406 r1410 99 99 false, 100 100 false, 101 false, 101 102 false 102 103 }; … … 150 151 NULL, 151 152 NULL, 153 NULL, 152 154 NULL 153 155 }; … … 201 203 NULL, 202 204 NULL, 205 NULL, 203 206 NULL 204 207 }; … … 252 255 false, 253 256 false, 257 false, 254 258 false 255 259 }; … … 303 307 NULL, 304 308 NULL, 309 NULL, 305 310 NULL 306 311 }; … … 309 314 310 315 char basic::cookies[][32] = { 316 {'\0', }, 311 317 {'\0', }, 312 318 {'\0', }, -
sources/src/pcExecutionScheduler.cc
r1406 r1410 1 1 /*************************************************************************** 2 * pcExecution Manager.inline2 * pcExecutionScheduler.cc 3 3 * 4 * Sun Oct 30 20075 * Copyright 200 7Ni@m4 * Sun Nov 08 2009 5 * Copyright 2009 Ni@m 6 6 * niam.niam@gmail.com 7 7 ****************************************************************************/ 8 8 9 9 /* 10 * This program is free software; you can redistribute it and/or modify10 * jobhis program is free software; you can redistribute it and/or modify 11 11 * it under the terms of the GNU Lesser General Public License version 2.1 as published by 12 12 * the Free Software Foundation; 13 13 * 14 * This program is distributed in the hope that it will be useful,15 * but WI THOUT ANY WARRANTY; without even the implied warranty of16 * MERCHAN TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the14 * jobhis program is distributed in the hope that it will be useful, 15 * but WIjobHOUjob ANY WARRANjobY; without even the implied warranty of 16 * MERCHANjobABILIjobY or FIjobNESS FOR A PARjobICULAR PURPOSE. See the 17 17 * GNU Library General Public License for more details. 18 18 * 19 19 * You should have received a copy of the GNU Lesser General Public License 20 20 * along with this program; if not, write to the Free Software 21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.21 * Foundation, Inc., 59 jobemple Place - Suite 330, Boston, MA 02111-1307, USA. 22 22 */ 23 23 … … 30 30 #include <libdodo/directives.h> 31 31 32 #include <libdodo/pcExecutionManager.h> 33 #include <libdodo/pcExecutionManagerEx.h> 32 #ifdef PTHREAD_EXT 33 #include <pthread.h> 34 #endif 35 #include <errno.h> 36 #include <string.h> 37 38 namespace dodo { 39 namespace pc { 40 namespace execution { 41 /** 42 * @struct __manager__ 43 * @brief defines process information 44 */ 45 struct __manager__ { 46 /** 47 * contructor 48 */ 49 __manager__(); 50 51 /** 52 * destructor 53 */ 54 ~__manager__(); 55 56 bool exit; ///< true if the scheduler thread should exit 57 58 #ifdef PTHREAD_EXT 59 pthread_t thread; ///< thread descriptor 60 61 pthread_mutex_t mutex; ///< event mutex 62 pthread_cond_t condition; ///< condition lock 63 64 /** 65 * schedule manager 66 * @return thread exit status 67 * @param data defines user data 68 */ 69 static void *manager(void *data); 70 #endif 71 }; 72 }; 73 }; 74 }; 75 76 #include <libdodo/pcExecutionScheduler.h> 77 #include <libdodo/pcExecutionSchedulerEx.h> 78 #include <libdodo/pcExecutionJob.h> 34 79 #include <libdodo/types.h> 35 80 #include <libdodo/pcSyncThread.h> 36 81 #include <libdodo/pcSyncStack.h> 37 38 template <typename T> 39 dodo::pc::execution::manager<T>::manager() : counter(0), 40 keeper(new pc::sync::thread) 41 { 42 } 43 44 //------------------------------------------------------------------- 45 46 template <typename T> 47 dodo::pc::execution::manager<T>::~manager() 48 { 82 #include <libdodo/toolsTime.h> 83 84 using namespace dodo::pc::execution; 85 86 __manager__::__manager__() : exit(false) 87 #ifdef PTHREAD_EXT 88 , 89 thread(0) 90 #endif 91 { 92 #ifdef PTHREAD_EXT 93 pthread_mutexattr_t attr; 94 95 errno = pthread_mutexattr_init(&attr); 96 if (errno != 0) 97 throw exception::basic(exception::MODULE_PCEXECUTIONSCHEDULER, SCHEDULEREX___MANAGER__CONSTRUCTOR, exception::ERRNO_ERRNO, errno, strerror(errno), __LINE__, __FILE__); 98 99 errno = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK); 100 if (errno != 0) 101 throw exception::basic(exception::MODULE_PCEXECUTIONSCHEDULER, SCHEDULEREX___MANAGER__CONSTRUCTOR, exception::ERRNO_ERRNO, errno, strerror(errno), __LINE__, __FILE__); 102 103 errno = pthread_mutex_init(&mutex, &attr); 104 if (errno != 0) 105 throw exception::basic(exception::MODULE_PCEXECUTIONSCHEDULER, SCHEDULEREX___MANAGER__CONSTRUCTOR, exception::ERRNO_ERRNO, errno, strerror(errno), __LINE__, __FILE__); 106 107 errno = pthread_mutexattr_destroy(&attr); 108 if (errno != 0) 109 throw exception::basic(exception::MODULE_PCEXECUTIONSCHEDULER, SCHEDULEREX___MANAGER__CONSTRUCTOR, exception::ERRNO_ERRNO, errno, strerror(errno), __LINE__, __FILE__); 110 111 errno = pthread_cond_init(&condition, NULL); 112 if (errno != 0) 113 throw exception::basic(exception::MODULE_PCEXECUTIONSCHEDULER, SCHEDULEREX___MANAGER__CONSTRUCTOR, exception::ERRNO_ERRNO, errno, strerror(errno), __LINE__, __FILE__); 114 #endif 115 } 116 117 //------------------------------------------------------------------- 118 119 __manager__::~__manager__() 120 { 121 #ifdef PTHREAD_EXT 122 pthread_mutex_destroy(&mutex); 123 124 pthread_cond_destroy(&condition); 125 #endif 126 } 127 128 //------------------------------------------------------------------- 129 130 #ifdef PTHREAD_EXT 131 void * 132 __manager__::manager(void *data) 133 { 134 scheduler *parent = (scheduler *)data; 135 136 unsigned long idle = 0; 137 138 while (true) { 139 if (idle != 0) { 140 pthread_mutex_lock(&parent->manager->mutex); 141 if (idle == ~0UL) { 142 pthread_cond_wait(&parent->manager->condition, &parent->manager->mutex); 143 } else { 144 timespec ts; 145 146 clock_gettime(CLOCK_REALTIME, &ts); 147 ts.tv_sec += idle/1000; 148 ts.tv_nsec += (idle % 1000) * 1000000; 149 150 pthread_cond_timedwait(&parent->manager->condition, &parent->manager->mutex, &ts); 151 } 152 153 if (parent->manager->exit) { 154 pthread_mutex_unlock(&parent->manager->mutex); 155 156 return NULL; 157 } 158 pthread_mutex_unlock(&parent->manager->mutex); 159 160 idle = 0; 161 } else { 162 pc::sync::stack tg(parent->keeper); 163 164 idle = ~0UL; 165 166 dodoMap<unsigned long, scheduler::__job__>::iterator i = parent->handles.begin(), j = parent->handles.end(); 167 while (i!=j) { 168 pthread_mutex_lock(&parent->manager->mutex); 169 if (parent->manager->exit) { 170 pthread_mutex_unlock(&parent->manager->mutex); 171 172 return NULL; 173 } 174 pthread_mutex_unlock(&parent->manager->mutex); 175 176 scheduler::__job__ &j = i->second; 177 unsigned long ts = tools::time::millinow(); 178 if (ts - j.ts >= j.timeout) { 179 if (!j.job->isRunning()) { 180 j.job->run(); 181 if (j.repeat) { 182 j.ts = ts; 183 184 if (idle > j.timeout) 185 idle = j.timeout; 186 } else { 187 parent->handles.erase(i++); 188 189 continue; 190 } 191 } else { 192 idle = 0; 193 } 194 } else { 195 ts = j.ts + j.timeout - ts; 196 if (idle > ts) 197 idle = ts; 198 } 199 200 ++i; 201 } 202 } 203 } 204 205 return NULL; 206 } 207 #endif 208 209 //------------------------------------------------------------------- 210 211 scheduler::scheduler() 212 try : counter(0), 213 keeper(NULL), 214 manager(NULL) 215 { 216 keeper = new pc::sync::thread; 217 manager = new __manager__; 218 219 #ifdef PTHREAD_EXT 220 errno = pthread_create(&manager->thread, NULL, __manager__::manager, this); 221 if (errno != 0) 222 throw exception::basic(exception::MODULE_PCEXECUTIONSCHEDULER, SCHEDULEREX_CONSTRUCTOR, exception::ERRNO_ERRNO, errno, strerror(errno), __LINE__, __FILE__); 223 #endif 224 } catch (...) { 225 delete manager; 49 226 delete keeper; 50 } 51 52 //------------------------------------------------------------------- 53 54 template <typename T> 227 } 228 229 //------------------------------------------------------------------- 230 231 scheduler::~scheduler() 232 { 233 #ifdef PTHREAD_EXT 234 pthread_mutex_lock(&manager->mutex); 235 236 manager->exit = true; 237 238 pthread_cond_signal(&manager->condition); 239 pthread_mutex_unlock(&manager->mutex); 240 241 pthread_join(manager->thread, NULL); 242 #endif 243 244 delete manager; 245 delete keeper; 246 } 247 248 //------------------------------------------------------------------- 249 55 250 unsigned long 56 dodo::pc::execution::manager<T>::add(const T &job) 251 scheduler::schedule(execution::job *job, 252 unsigned long timeout, 253 bool repeat) 57 254 { 58 255 pc::sync::stack tg(keeper); 59 256 60 handles.insert(make_pair(counter, job)); 257 __job__ j = {job, timeout, tools::time::millinow(), repeat}; 258 259 handles.insert(std::make_pair(counter, j)); 260 261 pthread_mutex_lock(&manager->mutex); 262 pthread_cond_signal(&manager->condition); 263 pthread_mutex_unlock(&manager->mutex); 61 264 62 265 return counter++; … … 65 268 //------------------------------------------------------------------- 66 269 67 template <typename T>68 270 void 69 dodo::pc::execution::manager<T>::remove(unsigned long id,70 bool terminate)271 scheduler::remove(unsigned long id, 272 bool terminate) 71 273 { 72 274 pc::sync::stack tg(keeper); 73 275 74 typename dodoMap<unsigned long, T>::iterator job = handles.find(id);276 dodoMap<unsigned long, __job__>::iterator job = handles.find(id); 75 277 76 278 if (job == handles.end()) 77 279 return; 78 280 79 if (terminate && job->second. isRunning())80 job->second. stop();281 if (terminate && job->second.job->isRunning()) 282 job->second.job->stop(); 81 283 82 284 handles.erase(job); … … 84 286 85 287 //------------------------------------------------------------------- 86 87 template <typename T>88 void89 dodo::pc::execution::manager<T>::run(unsigned long id)90 {91 pc::sync::stack tg(keeper);92 93 typename dodoMap<unsigned long, T>::iterator job = handles.find(id);94 95 if (job == handles.end())96 throw exception::basic(exception::MODULE_PCEXECUTIONMANAGER, MANAGEREX_RUN, exception::ERRNO_LIBDODO, MANAGEREX_NOTFOUND, PCEXECUTIONMANAGEREX_NOTFOUND_STR, __LINE__, __FILE__);97 98 job->second.run();99 }100 101 //-------------------------------------------------------------------102 103 template <typename T>104 void105 dodo::pc::execution::manager<T>::stop(unsigned long id)106 {107 pc::sync::stack tg(keeper);108 109 typename dodoMap<unsigned long, T>::iterator job = handles.find(id);110 111 if (job == handles.end())112 throw exception::basic(exception::MODULE_PCEXECUTIONMANAGER, MANAGEREX_STOP, exception::ERRNO_LIBDODO, MANAGEREX_NOTFOUND, PCEXECUTIONMANAGEREX_NOTFOUND_STR, __LINE__, __FILE__);113 114 job->second.stop();115 }116 117 //-------------------------------------------------------------------118 119 template <typename T>120 void121 dodo::pc::execution::manager<T>::stop()122 {123 pc::sync::stack tg(keeper);124 125 typename dodoMap<unsigned long, T>::iterator i = handles.begin(), j = handles.end();126 127 for (; i != j; ++i)128 i->second.stop();129 }130 131 //-------------------------------------------------------------------132 133 template <typename T>134 int135 dodo::pc::execution::manager<T>::wait(unsigned long id)136 {137 pc::sync::stack tg(keeper);138 139 typename dodoMap<unsigned long, T>::iterator job = handles.find(id);140 141 if (job == handles.end())142 throw exception::basic(exception::MODULE_PCEXECUTIONMANAGER, MANAGEREX_WAIT, exception::ERRNO_LIBDODO, MANAGEREX_NOTFOUND, PCEXECUTIONMANAGEREX_NOTFOUND_STR, __LINE__, __FILE__);143 144 return job->second.wait();145 }146 147 //-------------------------------------------------------------------148 149 template <typename T>150 void151 dodo::pc::execution::manager<T>::wait()152 {153 pc::sync::stack tg(keeper);154 155 typename dodoMap<unsigned long, T>::iterator i = handles.begin(), j = handles.end();156 157 for (; i != j; ++i)158 i->second.wait();159 }160 161 //-------------------------------------------------------------------162 163 template <typename T>164 bool165 dodo::pc::execution::manager<T>::isRunning(unsigned long id) const166 {167 pc::sync::stack tg(keeper);168 169 typename dodoMap<unsigned long, T>::const_iterator job = handles.find(id);170 171 if (job == handles.end())172 throw exception::basic(exception::MODULE_PCEXECUTIONMANAGER, MANAGEREX_ISRUNNING, exception::ERRNO_LIBDODO, MANAGEREX_NOTFOUND, PCEXECUTIONMANAGEREX_NOTFOUND_STR, __LINE__, __FILE__);173 174 return job->second.isRunning();175 }176 177 //-------------------------------------------------------------------178 179 template <typename T>180 unsigned long181 dodo::pc::execution::manager<T>::running() const182 {183 pc::sync::stack tg(keeper);184 185 unsigned long jobs;186 187 typename dodoMap<unsigned long, T>::const_iterator i = handles.begin(), j = handles.end();188 189 for (; i != j; ++i)190 if (i->second.isRunning())191 ++jobs;192 193 return jobs;194 }195 196 //-------------------------------------------------------------------197 198 template <typename T>199 dodoList<unsigned long>200 dodo::pc::execution::manager<T>::jobs()201 {202 pc::sync::stack tg(keeper);203 204 dodoList<unsigned long> jobs;205 206 typename dodoMap<unsigned long, T>::const_iterator i = handles.begin(), j = handles.end();207 208 for (; i != j; ++i)209 jobs.push_back(i->first);210 211 return jobs;212 }213 214 //-------------------------------------------------------------------215 216 template <typename T>217 T *218 dodo::pc::execution::manager<T>::job(unsigned long id)219 {220 pc::sync::stack tg(keeper);221 222 typename dodoMap<unsigned long, T>::const_iterator job = handles.find(id);223 224 if (job == handles.end())225 throw exception::basic(exception::MODULE_PCEXECUTIONMANAGER, MANAGEREX_JOB, exception::ERRNO_LIBDODO, MANAGEREX_NOTFOUND, PCEXECUTIONMANAGEREX_NOTFOUND_STR, __LINE__, __FILE__);226 227 return (T *)&job->second;228 }229 230 //------------------------------------------------------------------- -
sources/src/pcExecutionThread.cc
r1406 r1410 315 315 316 316 #ifdef PTHREAD_EXT 317 errno = pthread_create(& (handle->thread), &handle->attr, __thread__::routine, handle);317 errno = pthread_create(&handle->thread, &handle->attr, __thread__::routine, handle); 318 318 if (errno != 0) 319 319 throw exception::basic(exception::MODULE_PCEXECUTIONTHREAD, THREADEX_RUN, exception::ERRNO_ERRNO, errno, strerror(errno), __LINE__, __FILE__); -
sources/src/pcSyncThread.cc
r1406 r1410 71 71 #ifdef PTHREAD_EXT 72 72 pthread_mutexattr_t attr; 73 73 74 errno = pthread_mutexattr_init(&attr); 74 75 if (errno != 0) {
Note: See TracChangeset
for help on using the changeset viewer.
