/*
    Robot Interface
    (C) 2006 Jason Hunt
    nulluser@gmail.com
    
    File: time.cpp
*/

#include <windows.h>


CRITICAL_SECTION time_lock;

void time_start( void )
{
    InitializeCriticalSection(&time_lock);       
}



/* Return current time in seconds */
double get_time( void )
{
    EnterCriticalSection(&time_lock);           

    static LARGE_INTEGER freq;
    bool init = 0;

    if (!init)
    {
        QueryPerformanceFrequency(&freq);
        init = 1;
    }

    LARGE_INTEGER c;

    QueryPerformanceCounter(&c);

    double value = c.QuadPart / (double)freq.QuadPart;
    
    LeaveCriticalSection(&time_lock);
    
    return(value);
}
/* End of get_time */





