Author

Topic: Is GetPerformanceCounter() thread safe? (Read 711 times)

member
Activity: 64
Merit: 10
btc.com
September 17, 2013, 02:55:39 AM
#1
gettimeofday() is a non-thread safe function, I think here should add mutex lock.

Quote
inline int64 GetPerformanceCounter()
{           
    int64 nCounter = 0;
#ifdef WIN32
    QueryPerformanceCounter((LARGE_INTEGER*)&nCounter);
#else       
    timeval t;
    gettimeofday(&t, NULL);
    nCounter = (int64) t.tv_sec * 1000000 + t.tv_usec;
#endif       
    return nCounter;
}
Jump to: