Changeset 1472:bbc6ac5ec16d


Ignore:
Timestamp:
08/27/10 05:06:10 (18 months ago)
Author:
niam
Branch:
default
Message:

[time] renamed millinow->nowMs, microSleep->sleepUs; added sleepMs

Location:
sources
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • sources/examples/pc_job/test.cc

    r1464 r1472  
    1818{ 
    1919    dodo_try { 
    20         cout << endl << (char *)data << ": " << tools::time::millinow() << endl; 
     20        cout << endl << (char *)data << ": " << tools::time::nowMs() << endl; 
    2121    } dodo_catch (exception::basic *e)   { 
    2222        cout << (dodo::string)*e << "\t" << e->line << "\t" << e->file << endl; 
     
    3030{ 
    3131    dodo_try { 
    32         cout << endl << ">>" << (char *)data << ": " << tools::time::millinow() << endl; 
     32        cout << endl << ">>" << (char *)data << ": " << tools::time::nowMs() << endl; 
    3333 
    3434        tools::os::sleep(tools::string::stringToUL((char *)data)); 
    3535 
    36         cout << endl << "<<" << (char *)data << ": " << tools::time::millinow() << endl; 
     36        cout << endl << "<<" << (char *)data << ": " << tools::time::nowMs() << endl; 
    3737    } dodo_catch (exception::basic *e)   { 
    3838        cout << (dodo::string)*e << "\t" << e->line << "\t" << e->file << endl; 
     
    7171 
    7272        cout << "Launching jobs" << endl; 
    73         cout << tools::time::millinow() << endl; 
     73        cout << tools::time::nowMs() << endl; 
    7474 
    7575        for (int i = 0; i < amount; ++i) 
     
    7979            cout << "Job #"<< pos[i] << " is " << (manager.isRunning(pos[i])?"running":"not running") << endl; 
    8080 
    81         cout << tools::time::millinow() << endl; 
     81        cout << tools::time::nowMs() << endl; 
    8282        tools::os::sleep(2); 
    83         cout << tools::time::millinow() << endl; 
     83        cout << tools::time::nowMs() << endl; 
    8484        scheduler.remove(pID); 
    8585 
     
    8888 
    8989        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; 
    9191        tools::os::sleep(2); 
    9292        scheduler.remove(pID); 
    93         cout << tools::time::millinow() << endl; 
     93        cout << tools::time::nowMs() << endl; 
    9494        tools::os::sleep(2); 
    95         cout << tools::time::millinow() << endl; 
     95        cout << tools::time::nowMs() << endl; 
    9696 
    9797        for (int i = 0; i < amount; ++i) 
  • sources/examples/pc_process/test.cc

    r1464 r1472  
    3838 
    3939        cout << (char *)data0.acquire(1), cout.flush(); 
    40         tools::os::microSleep(1000); 
     40        tools::os::sleepMs(1); 
    4141        data0.release(); 
    4242 
  • sources/examples/pc_workqueue/test.cc

    r1468 r1472  
    2323        lock.acquire(); 
    2424        ++done; 
    25         cout << "#" << done << ": NULL : " << tools::time::millinow() << endl, cout.flush(); 
     25        cout << "#" << done << ": NULL : " << tools::time::nowMs() << endl, cout.flush(); 
    2626        lock.release(); 
    2727 
     
    3535        lock.acquire(); 
    3636        ++done; 
    37         cout << "#" << done << ": " << (char *)data << ": " << tools::time::millinow() << endl, cout.flush(); 
     37        cout << "#" << done << ": " << (char *)data << ": " << tools::time::nowMs() << endl, cout.flush(); 
    3838        lock.release(); 
    3939    } dodo_catch (exception::basic *e)   { 
     
    5353        tools::os::sleep(1); 
    5454 
    55         cout << "Launching jobs: " << tools::time::millinow() << endl; 
     55        cout << "Launching jobs: " << tools::time::nowMs() << endl; 
    5656 
    5757        for (int i=0;i<100;++i) 
  • sources/include/libdodo/toolsOs.h

    r1439 r1472  
    216216 
    217217            /** 
    218              * suspend 
     218             * suspend for given timeout 
    219219             * @param period defines time in microseconds 
    220220             */ 
    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 
    225231             * @param period defines time in seconds 
    226232             */ 
    227             static void sleep(long period); 
     233            static void sleep(unsigned long period); 
    228234 
    229235            /** 
  • sources/include/libdodo/toolsTime.h

    r1439 r1472  
    139139             * @return number of milliseconds from 00:00:00 UTC, January 1, 1970 till now 
    140140             */ 
    141             static unsigned long millinow(); 
     141            static unsigned long nowMs(); 
    142142 
    143143            /** 
  • sources/src/pcExecutionScheduler.cc

    r1471 r1472  
    177177 
    178178                scheduler::__job__ &j = i->second; 
    179                 unsigned long ts = tools::time::millinow(); 
     179                unsigned long ts = tools::time::nowMs(); 
    180180                if (ts - j.ts >= j.timeout) { 
    181181                    if (!j.job->isRunning()) { 
     
    278278    } 
    279279 
    280     __job__ j = {_job, timeout, tools::time::millinow(), repeat}; 
     280    __job__ j = {_job, timeout, tools::time::nowMs(), repeat}; 
    281281 
    282282    handles.insert(std::make_pair(counter, j)); 
  • sources/src/toolsOs.cc

    r1464 r1472  
    605605 
    606606void 
    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) 
     607os::sleepMs(unsigned long period) 
     608{ 
     609    timespec ts = {period/1000, (period%1000)*1000000}; 
     610 
     611    nanosleep(&ts, NULL); 
     612} 
     613 
     614//------------------------------------------------------------------- 
     615 
     616void 
     617os::sleepUs(unsigned long period) 
     618{ 
     619    timespec ts = {period/1000000, (period%1000000)*1000}; 
     620 
     621    nanosleep(&ts, NULL); 
     622} 
     623 
     624//------------------------------------------------------------------- 
     625 
     626void 
     627os::sleep(unsigned long period) 
    619628{ 
    620629    ::sleep(period); 
  • sources/src/toolsTime.cc

    r1464 r1472  
    9898 
    9999unsigned long 
    100 tools::time::millinow() 
     100tools::time::nowMs() 
    101101{ 
    102102    timeval tv; 
Note: See TracChangeset for help on using the changeset viewer.