javamanager/javacaptain/src/tickerproviderinterface.h
branchRCL_3
changeset 60 6c158198356e
parent 19 04becd199f91
equal deleted inserted replaced
59:e5618cc85d74 60:6c158198356e
    62     virtual void cancel() = 0;
    62     virtual void cancel() = 0;
    63 
    63 
    64     // Helpers
    64     // Helpers
    65     /**
    65     /**
    66     * Returns milliseconds from EPOCH.
    66     * Returns milliseconds from EPOCH.
       
    67     * This can be overridden with the platform specific implementation. Use case for
       
    68     * overriding is that in some platforms gettimeofday implementation can't handle
       
    69     * correctly times after 2038.
       
    70     * @param[in]  -
       
    71     * @return - milliseconds from EPOCH in success, -1 if fails
       
    72     */
       
    73     virtual long long getPlatformCurrentJavaTime()
       
    74     {
       
    75         return -1LL;
       
    76     }
       
    77 
       
    78     /**
       
    79     * Returns milliseconds from EPOCH.
    67     * @param[in]  -
    80     * @param[in]  -
    68     * @return - milliseconds from EPOCH in success, -1 if fails
    81     * @return - milliseconds from EPOCH in success, -1 if fails
    69     */
    82     */
    70     virtual long long getCurrentJavaTime()
    83     virtual long long getCurrentJavaTime()
    71     {
    84     {
    72         timeval tim;
    85         timeval tim;
    73         int err = gettimeofday(&tim, NULL);
    86         int err = gettimeofday(&tim, NULL);
    74         if (-1 == err)
    87         if (-1 == err)
    75         {
    88         {
    76             return -1LL;
    89             WLOG(EJavaCaptain, "getCurrentJavaTime: gettimeofday returned -1");
       
    90             return getPlatformCurrentJavaTime();
    77         }
    91         }
    78 
    92 
    79         return (tim.tv_sec * 1000LL) +
    93         return (tim.tv_sec * 1000LL) +
    80                (tim.tv_usec / 1000LL);
    94                (tim.tv_usec / 1000LL);
    81     }
    95     }