#else
#include <time.h>
#endif
+#include "SystemClock.h"
namespace XbmcThreads
{
}
return (unsigned int)(now_time - start_time);
}
+ const unsigned int EndTime::InfiniteValue = std::numeric_limits<unsigned int>::max();
}
unsigned int startTime;
unsigned int totalWaitTime;
public:
+ static const unsigned int InfiniteValue;
inline EndTime() : startTime(0), totalWaitTime(0) {}
inline EndTime(unsigned int millisecondsIntoTheFuture) : startTime(SystemClockMillis()), totalWaitTime(millisecondsIntoTheFuture) {}
inline void Set(unsigned int millisecondsIntoTheFuture) { startTime = SystemClockMillis(); totalWaitTime = millisecondsIntoTheFuture; }
- inline bool IsTimePast() { return totalWaitTime == 0 ? true : (SystemClockMillis() - startTime) >= totalWaitTime; }
+ inline bool IsTimePast() { return totalWaitTime == InfiniteValue ? false : (totalWaitTime == 0 ? true : (SystemClockMillis() - startTime) >= totalWaitTime); }
inline unsigned int MillisLeft()
{
+ if (totalWaitTime == InfiniteValue)
+ return InfiniteValue;
unsigned int timeWaitedAlready = (SystemClockMillis() - startTime);
return (timeWaitedAlready >= totalWaitTime) ? 0 : (totalWaitTime - timeWaitedAlready);
}
inline void SetExpired() { totalWaitTime = 0; }
- inline void SetInfinite() { totalWaitTime = std::numeric_limits<unsigned int>::max(); }
+ inline void SetInfinite() { totalWaitTime = InfiniteValue; }
};
}