gettimeofday() could be affected by ntp kinda things. If using it for timeout logic there could be wrong, e.g. time goes backwards. We could clock_gettime() with CLOCK_MONOTONIC as an alternative.
For some platforms/oses that does not have the support for clock_gettime(), we can fall back to use gettimeofday().
Note getCurrentTime() in code is a good example.