Starboard Module Reference: time.h

Provides access to system time and timers.

Functions

SbTimeFromPosix

Description

Converts microseconds from the POSIX epoch into an SbTime.

Declaration

static SB_C_FORCE_INLINE SbTime SbTimeFromPosix(int64_t time) {
  return time - kSbTimeToPosixDelta;
}

Parameters

Parameters
int64_t
time
A time that measures the number of microseconds since January 1, 1970, 00:00:00, UTC.

SbTimeGetMonotonicNow

Description

Gets a monotonically increasing time representing right now.

Declaration and definitions

SB_EXPORT SbTimeMonotonic SbTimeGetMonotonicNow();

#include "starboard/time.h"

SbTimeMonotonic SbTimeGetMonotonicNow() {
  return SbTimeMonotonic();
}

SbTimeGetMonotonicThreadNow

Description

Gets a monotonically increasing time representing how long the current thread has been in the executing state (i.e. not pre-empted nor waiting on an event). This is not necessarily total time and is intended to allow measuring thread execution time between two timestamps. If this is not available then SbTimeGetMonotonicNow() should be used.

Declaration and definitions

SB_EXPORT SbTimeMonotonic SbTimeGetMonotonicThreadNow();

#include "starboard/time.h"

SbTimeMonotonic SbTimeGetMonotonicThreadNow() {
  return SbTimeMonotonic(0);
}

SbTimeGetNow

Description

Gets the current system time as an SbTime.

Declaration and definitions

SB_EXPORT SbTime SbTimeGetNow();

#include "starboard/time.h"

SbTime SbTimeGetNow() {
  return SbTime();
}

SbTimeNarrow

Description

Safely narrows a number from a more precise unit to a less precise one. This function rounds negative values toward negative infinity.

Declaration

static SB_C_FORCE_INLINE int64_t SbTimeNarrow(int64_t time, int64_t divisor) {
  return time >= 0 ? time / divisor : (time - divisor + 1) / divisor;
}

Parameters

Parameters
int64_t
time
int64_t
divisor

SbTimeToPosix

Description

Converts SbTime into microseconds from the POSIX epoch.

Declaration

static SB_C_FORCE_INLINE int64_t SbTimeToPosix(SbTime time) {
  return time + kSbTimeToPosixDelta;
}

Parameters

Parameters
SbTime
time
A time that is either measured in microseconds since the epoch of January 1, 1601, UTC, or that measures the number of microseconds between two times.