Changeset 1472:bbc6ac5ec16d
- Timestamp:
- 08/27/10 05:06:10 (18 months ago)
- Branch:
- default
- Location:
- sources
- Files:
-
- 8 edited
-
examples/pc_job/test.cc (modified) (5 diffs)
-
examples/pc_process/test.cc (modified) (1 diff)
-
examples/pc_workqueue/test.cc (modified) (3 diffs)
-
include/libdodo/toolsOs.h (modified) (1 diff)
-
include/libdodo/toolsTime.h (modified) (1 diff)
-
src/pcExecutionScheduler.cc (modified) (2 diffs)
-
src/toolsOs.cc (modified) (1 diff)
-
src/toolsTime.cc (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
sources/examples/pc_job/test.cc
r1464 r1472 18 18 { 19 19 dodo_try { 20 cout << endl << (char *)data << ": " << tools::time:: millinow() << endl;20 cout << endl << (char *)data << ": " << tools::time::nowMs() << endl; 21 21 } dodo_catch (exception::basic *e) { 22 22 cout << (dodo::string)*e << "\t" << e->line << "\t" << e->file << endl; … … 30 30 { 31 31 dodo_try { 32 cout << endl << ">>" << (char *)data << ": " << tools::time:: millinow() << endl;32 cout << endl << ">>" << (char *)data << ": " << tools::time::nowMs() << endl; 33 33 34 34 tools::os::sleep(tools::string::stringToUL((char *)data)); 35 35 36 cout << endl << "<<" << (char *)data << ": " << tools::time:: millinow() << endl;36 cout << endl << "<<" << (char *)data << ": " << tools::time::nowMs() << endl; 37 37 } dodo_catch (exception::basic *e) { 38 38 cout << (dodo::string)*e << "\t" << e->line << "\t" << e->file << endl; … … 71 71 72 72 cout << "Launching jobs" << endl; 73 cout << tools::time:: millinow() << endl;73 cout << tools::time::nowMs() << endl; 74 74 75 75 for (int i = 0; i < amount; ++i) … … 79 79 cout << "Job #"<< pos[i] << " is " << (manager.isRunning(pos[i])?"running":"not running") << endl; 80 80 81 cout << tools::time:: millinow() << endl;81 cout << tools::time::nowMs() << endl; 82 82 tools::os::sleep(2); 83 cout << tools::time:: millinow() << endl;83 cout << tools::time::nowMs() << endl; 84 84 scheduler.remove(pID); 85 85 … … 88 88 89 89 pID = scheduler.schedule(execution::thread(::job0, (void *)"periodic", execution::ON_DESTRUCTION_STOP), 100, true); 90 cout << tools::time:: millinow() << endl;90 cout << tools::time::nowMs() << endl; 91 91 tools::os::sleep(2); 92 92 scheduler.remove(pID); 93 cout << tools::time:: millinow() << endl;93 cout << tools::time::nowMs() << endl; 94 94 tools::os::sleep(2); 95 cout << tools::time:: millinow() << endl;95 cout << tools::time::nowMs() << endl; 96 96 97 97 for (int i = 0; i < amount; ++i) -
sources/examples/pc_process/test.cc
r1464 r1472 38 38 39 39 cout << (char *)data0.acquire(1), cout.flush(); 40 tools::os:: microSleep(1000);40 tools::os::sleepMs(1); 41 41 data0.release(); 42 42 -
sources/examples/pc_workqueue/test.cc
r1468 r1472 23 23 lock.acquire(); 24 24 ++done; 25 cout << "#" << done << ": NULL : " << tools::time:: millinow() << endl, cout.flush();25 cout << "#" << done << ": NULL : " << tools::time::nowMs() << endl, cout.flush(); 26 26 lock.release(); 27 27 … … 35 35 lock.acquire(); 36 36 ++done; 37 cout << "#" << done << ": " << (char *)data << ": " << tools::time:: millinow() << endl, cout.flush();37 cout << "#" << done << ": " << (char *)data << ": " << tools::time::nowMs() << endl, cout.flush(); 38 38 lock.release(); 39 39 } dodo_catch (exception::basic *e) { … … 53 53 tools::os::sleep(1); 54 54 55 cout << "Launching jobs: " << tools::time:: millinow() << endl;55 cout << "Launching jobs: " << tools::time::nowMs() << endl; 56 56 57 57 for (int i=0;i<100;++i) -
sources/include/libdodo/toolsOs.h
r1439 r1472 216 216 217 217 /** 218 * suspend 218 * suspend for given timeout 219 219 * @param period defines time in microseconds 220 220 */ 221 static void microSleep(unsigned long period); 222 223 /** 224 * suspend 221 static void sleepUs(unsigned long period); 222 223 /** 224 * suspend for given timeout 225 * @param period defines time in milliseconds 226 */ 227 static void sleepMs(unsigned long period); 228 229 /** 230 * suspend for given timeout 225 231 * @param period defines time in seconds 226 232 */ 227 static void sleep( long period);233 static void sleep(unsigned long period); 228 234 229 235 /** -
sources/include/libdodo/toolsTime.h
r1439 r1472 139 139 * @return number of milliseconds from 00:00:00 UTC, January 1, 1970 till now 140 140 */ 141 static unsigned long millinow();141 static unsigned long nowMs(); 142 142 143 143 /** -
sources/src/pcExecutionScheduler.cc
r1471 r1472 177 177 178 178 scheduler::__job__ &j = i->second; 179 unsigned long ts = tools::time:: millinow();179 unsigned long ts = tools::time::nowMs(); 180 180 if (ts - j.ts >= j.timeout) { 181 181 if (!j.job->isRunning()) { … … 278 278 } 279 279 280 __job__ j = {_job, timeout, tools::time:: millinow(), repeat};280 __job__ j = {_job, timeout, tools::time::nowMs(), repeat}; 281 281 282 282 handles.insert(std::make_pair(counter, j)); -
sources/src/toolsOs.cc
r1464 r1472 605 605 606 606 void 607 os::microSleep(unsigned long period) 608 { 609 if (period < 1000000) 610 ::usleep(period); 611 else 612 ::sleep(period / 1000000); 613 } 614 615 //------------------------------------------------------------------- 616 617 void 618 os::sleep(long period) 607 os::sleepMs(unsigned long period) 608 { 609 timespec ts = {period/1000, (period%1000)*1000000}; 610 611 nanosleep(&ts, NULL); 612 } 613 614 //------------------------------------------------------------------- 615 616 void 617 os::sleepUs(unsigned long period) 618 { 619 timespec ts = {period/1000000, (period%1000000)*1000}; 620 621 nanosleep(&ts, NULL); 622 } 623 624 //------------------------------------------------------------------- 625 626 void 627 os::sleep(unsigned long period) 619 628 { 620 629 ::sleep(period); -
sources/src/toolsTime.cc
r1464 r1472 98 98 99 99 unsigned long 100 tools::time:: millinow()100 tools::time::nowMs() 101 101 { 102 102 timeval tv;
Note: See TracChangeset
for help on using the changeset viewer.
