Changeset 1417:af5cb44c12fc
- Timestamp:
- 11/22/09 16:42:53 (2 years ago)
- Branch:
- default
- Location:
- sources
- Files:
-
- 7 edited
-
examples/pc_job/test.cc (modified) (2 diffs)
-
include/libdodo/pcExecutionJob.h (modified) (2 diffs)
-
include/libdodo/pcExecutionManagerEx.h (modified) (1 diff)
-
include/libdodo/pcExecutionScheduler.h (modified) (1 diff)
-
include/libdodo/pcExecutionSchedulerEx.h (modified) (2 diffs)
-
src/pcExecutionManager.cc (modified) (1 diff)
-
src/pcExecutionScheduler.cc (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
sources/examples/pc_job/test.cc
r1415 r1417 49 49 const int amount = 10; 50 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 51 execution::scheduler scheduler; 55 52 56 unsigned long pID = scheduler.schedule( &periodic, 1000, true);57 scheduler.schedule( &oneshot0, 2000);58 scheduler.schedule( &oneshot1, 3000);53 unsigned long pID = scheduler.schedule(execution::thread(::job0, (void *)"periodic", execution::ON_DESTRUCTION_STOP), 1000, true); 54 scheduler.schedule(execution::thread(::job0, (void *)"oneshot thread", execution::ON_DESTRUCTION_STOP), 2000); 55 scheduler.schedule(execution::process(::job0, (void *)"oneshot process", execution::ON_DESTRUCTION_STOP), 3000); 59 56 60 57 execution::manager manager; … … 90 87 cout << "Job #"<< pos[i] << " is " << (manager.isRunning(pos[i])?"running":"not running") << endl; 91 88 92 pID = scheduler.schedule( &periodic, 100, true);89 pID = scheduler.schedule(execution::thread(::job0, (void *)"periodic", execution::ON_DESTRUCTION_STOP), 100, true); 93 90 cout << tools::time::millinow() << endl; 94 91 tools::os::sleep(2); -
sources/include/libdodo/pcExecutionJob.h
r1415 r1417 39 39 namespace execution { 40 40 class manager; 41 class scheduler; 41 42 42 43 /** … … 62 63 class job { 63 64 friend class manager; 65 friend class scheduler; 64 66 65 67 public: -
sources/include/libdodo/pcExecutionManagerEx.h
r1415 r1417 51 51 #define PCEXECUTIONMANAGEREX_NOTFOUND_STR "Job was not found" 52 52 #define PCEXECUTIONMANAGEREX_UNKNOWNJOB_STR "Unknown type of job" 53 53 54 /** 54 55 * ID of function where exception was thrown -
sources/include/libdodo/pcExecutionScheduler.h
r1410 r1417 72 72 * @param repeat defines if job should be rescheduled again 73 73 */ 74 unsigned long schedule( execution::job *job,74 unsigned long schedule(const execution::job &job, 75 75 unsigned long timeout, 76 76 bool repeat = false); -
sources/include/libdodo/pcExecutionSchedulerEx.h
r1410 r1417 39 39 namespace execution { 40 40 /** 41 * libdodo defined errors 42 */ 43 enum schedulerExR { 44 SCHEDULEREX_UNKNOWNJOB, 45 }; 46 47 /** 48 * libdodo defined errors explanation 49 */ 50 #define PCEXECUTIONSCHEDULEREX_UNKNOWNJOB_STR "Unknown type of job" 51 52 /** 41 53 * ID of function where exception was thrown 42 54 */ … … 44 56 SCHEDULEREX___MANAGER__CONSTRUCTOR, 45 57 SCHEDULEREX_CONSTRUCTOR, 58 SCHEDULEREX_SCHEDULE, 46 59 }; 47 60 }; -
sources/src/pcExecutionManager.cc
r1415 r1417 81 81 82 82 default: 83 throw exception::basic(exception::MODULE_PCEXECUTIONMANAGER, MANAGEREX_ RUN, exception::ERRNO_LIBDODO, MANAGEREX_UNKNOWNJOB, PCEXECUTIONMANAGEREX_UNKNOWNJOB_STR, __LINE__, __FILE__);83 throw exception::basic(exception::MODULE_PCEXECUTIONMANAGER, MANAGEREX_ADD, exception::ERRNO_LIBDODO, MANAGEREX_UNKNOWNJOB, PCEXECUTIONMANAGEREX_UNKNOWNJOB_STR, __LINE__, __FILE__); 84 84 } 85 85 -
sources/src/pcExecutionScheduler.cc
r1410 r1417 77 77 #include <libdodo/pcExecutionSchedulerEx.h> 78 78 #include <libdodo/pcExecutionJob.h> 79 #include <libdodo/pcExecutionThread.h> 80 #include <libdodo/pcExecutionProcess.h> 79 81 #include <libdodo/types.h> 80 82 #include <libdodo/pcSyncThread.h> … … 249 251 250 252 unsigned long 251 scheduler::schedule( execution::job *job,253 scheduler::schedule(const execution::job &job, 252 254 unsigned long timeout, 253 255 bool repeat) … … 255 257 pc::sync::stack tg(keeper); 256 258 257 __job__ j = {job, timeout, tools::time::millinow(), repeat}; 259 execution::job *_job; 260 261 execution::job *orig = const_cast<execution::job *>(&job); 262 263 switch (job.type) { 264 case execution::job::TYPE_PROCESS: 265 _job = new process(*dynamic_cast<process *>(orig)); 266 267 break; 268 269 case execution::job::TYPE_THREAD: 270 _job = new thread(*dynamic_cast<thread *>(orig)); 271 272 break; 273 274 default: 275 throw exception::basic(exception::MODULE_PCEXECUTIONSCHEDULER, SCHEDULEREX_SCHEDULE, exception::ERRNO_LIBDODO, SCHEDULEREX_UNKNOWNJOB, PCEXECUTIONSCHEDULEREX_UNKNOWNJOB_STR, __LINE__, __FILE__); 276 } 277 278 __job__ j = {_job, timeout, tools::time::millinow(), repeat}; 258 279 259 280 handles.insert(std::make_pair(counter, j));
Note: See TracChangeset
for help on using the changeset viewer.
