Fix comments. add convenience macro

This commit is contained in:
Nils O. Selåsdal
2013-03-07 21:38:07 +01:00
parent b80c2f633f
commit 40f34b2bcd
+19 -9
View File
@@ -23,6 +23,12 @@ struct UCoreClock {
void (*now)(struct UCoreClock *clock, struct timeval *tv); void (*now)(struct UCoreClock *clock, struct timeval *tv);
}; };
/** Convenience macro for geting the time from a UCoreClock
* @param uclock pointer to the clock
* @param tv struct timeval pointer that will be filled in.
*/
#define UCORE_CLOCK_NOW(uclock, tv) (uclock)->now((uclock), (tv))
/** A cached clock where clock.now() returns /** A cached clock where clock.now() returns
* the cached value. The cache is updated * the cached value. The cache is updated
@@ -34,7 +40,7 @@ struct UCoreCachedClock {
struct UCoreClock clock; struct UCoreClock clock;
/** The underlying real clock*/ /** The underlying real clock*/
struct UCoreClock *real_clock; struct UCoreClock *real_clock;
/** cached value */ /** Cached value */
struct timeval cache; struct timeval cache;
}; };
@@ -45,7 +51,6 @@ struct UCoreCachedClock {
struct UCoreSettableClock { struct UCoreSettableClock {
/** The clock*/ /** The clock*/
struct UCoreClock clock; struct UCoreClock clock;
/** The underlying real clock*/
/** Current value */ /** Current value */
struct timeval now; struct timeval now;
}; };
@@ -62,9 +67,13 @@ extern struct UCoreClock uc_timeofday_clock;
extern struct UCoreClock uc_time_clock; extern struct UCoreClock uc_time_clock;
/** /**
* Initialize a cached clock where now() calls time(). * Initialize a cached clock whose now() is a cached
* This clock will this just have seconds resolution. * value of the real_clock.
* @param clock clock to initialize *
* @param uclock clock to initialize
* @param real_clock underlying clock that updates
* the cache.
*
*/ */
void uc_cached_clock_init(struct UCoreCachedClock *uclock, void uc_cached_clock_init(struct UCoreCachedClock *uclock,
struct UCoreClock *real_clock); struct UCoreClock *real_clock);
@@ -75,9 +84,10 @@ void uc_cached_clock_update(struct UCoreCachedClock *uclock);
/** /**
* Initialize a user settable where now() calls time(). * Initialize a user settable clock, where now()
* This clock will this just have seconds resolution. * returns the user set time.
* @param clock clock to initialize *
* @param clock uclock to initialize
*/ */
void uc_settable_clock_init(struct UCoreSettableClock *uclock); void uc_settable_clock_init(struct UCoreSettableClock *uclock);
@@ -88,7 +98,7 @@ void uc_settable_clock_set_tv(struct UCoreSettableClock *uclock,
const struct timeval *tv); const struct timeval *tv);
/** /**
* Set the new timeval this clock will return * Set the new time this clock will return
* Convenience function that takes seconds/microseconds as arguments * Convenience function that takes seconds/microseconds as arguments
* instead of a struct timeval. * instead of a struct timeval.
**/ **/