Changeset 307 in flair-src for trunk/lib/FlairCore/src/Thread.cpp


Ignore:
Timestamp:
03/08/19 10:30:25 (3 years ago)
Author:
Sanahuja Guillaume
Message:

resove bug in times

Location:
trunk/lib/FlairCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/FlairCore

    • Property svn:ignore set to
      build_x86_64
      build_core2_64
      build_armv7a_neon
      build_armv5te
      build_arm
      build
      .codelite
      .clang
  • trunk/lib/FlairCore/src/Thread.cpp

    r252 r307  
    9898#else
    9999  Time current = GetTime();
     100
    100101  if (current < time) {
    101102    //usleep((time - current) / 1000);
     103    Time tmp=time - current;
    102104    struct timespec req;
    103     req.tv_nsec = time - current;
    104     req.tv_sec = req.tv_nsec / 1000000000;
    105     req.tv_nsec %= 1000000000;
     105    req.tv_sec = tmp / (Time)1000000000;
     106    req.tv_nsec = tmp%(Time)1000000000;
    106107    struct timespec rem;
    107108    if(nanosleep(&req,&rem)!=0) Err("error in nanosleep\n");//todo, handle EINTR
     
    113114
    114115void Thread::SleepMS(uint32_t time) const {
    115 #ifdef __XENO__
    116   int status = rt_task_sleep(time * 1000 * 1000);
    117   if (status != 0) {
    118                 char errorMsg[256];
    119     Err("erreur rt_task_sleep (%s)\n", strerror_r(-status, errorMsg, sizeof(errorMsg)));
    120         }
    121 #else
    122   //usleep(time * 1000);
    123   struct timespec req;
    124   req.tv_nsec = time * 1000000;
    125   req.tv_sec = req.tv_nsec / 1000000000;
    126   req.tv_nsec %= 1000000000;
    127   struct timespec rem;
    128   if(nanosleep(&req,&rem)!=0) Err("error in nanosleep\n");//todo, handle EINTR
    129 #endif
     116    SleepUS(time*1000);
    130117}
    131118
     
    140127  //usleep(time);
    141128  struct timespec req;
    142   req.tv_nsec = time * 1000;
    143   req.tv_sec = req.tv_nsec / 1000000000;
    144   req.tv_nsec %= 1000000000;
     129  req.tv_sec = (Time)time / (Time)1000;
     130  req.tv_nsec = (Time)time%(Time)1000;
    145131  struct timespec rem;
    146132  if(nanosleep(&req,&rem)!=0) Err("error in nanosleep\n");//todo, handle EINTR
Note: See TracChangeset for help on using the changeset viewer.