Back to index

unity  6.0.0
Static Public Member Functions
unity::TimeUtil Class Reference

#include <TimeUtil.h>

List of all members.

Static Public Member Functions

static int TimeDelta (struct timespec const *x, struct timespec const *y)
static void SetTimeStruct (struct timespec *timer, struct timespec *sister=0, int sister_relation=0)
static void SetTimeBack (struct timespec *timeref, int remove)

Detailed Description

Definition at line 25 of file TimeUtil.h.


Member Function Documentation

static void unity::TimeUtil::SetTimeBack ( struct timespec *  timeref,
int  remove 
) [inline, static]

Definition at line 53 of file TimeUtil.h.

  {
    timeref->tv_sec -= remove / 1000;
    remove = remove % 1000;

    if (remove > timeref->tv_nsec / 1000000)
    {
      timeref->tv_sec--;
      timeref->tv_nsec += 1000000000;
    }
    timeref->tv_nsec -= remove * 1000000;
  }

Here is the caller graph for this function:

static void unity::TimeUtil::SetTimeStruct ( struct timespec *  timer,
struct timespec *  sister = 0,
int  sister_relation = 0 
) [inline, static]

Definition at line 33 of file TimeUtil.h.

  {
    struct timespec current;
    clock_gettime(CLOCK_MONOTONIC, &current);

    if (sister)
    {
      int diff = TimeDelta(&current, sister);

      if (diff < sister_relation)
      {
        int remove = sister_relation - diff;
        SetTimeBack(&current, remove);
      }
    }

    timer->tv_sec = current.tv_sec;
    timer->tv_nsec = current.tv_nsec;
  }

Here is the call graph for this function:

Here is the caller graph for this function:

static int unity::TimeUtil::TimeDelta ( struct timespec const *  x,
struct timespec const *  y 
) [inline, static]

Definition at line 28 of file TimeUtil.h.

  {
    return ((x->tv_sec - y->tv_sec) * 1000) + ((x->tv_nsec - y->tv_nsec) / 1000000);
  }

Here is the caller graph for this function:


The documentation for this class was generated from the following file: