timer is redundant

This commit is contained in:
Nguyen Anh Quynh
2017-01-20 16:46:58 +08:00
parent 6daa8581cd
commit fff532fc20
4 changed files with 3 additions and 435 deletions

View File

@ -105,314 +105,6 @@ static inline int64_t qemu_clock_get_us(QEMUClockType type)
return qemu_clock_get_ns(type) / SCALE_US;
}
/*
* QEMUTimerList
*/
/**
* timerlist_new:
* @type: the clock type to associate with the timerlist
* @cb: the callback to call on notification
* @opaque: the opaque pointer to pass to the callback
*
* Create a new timerlist associated with the clock of
* type @type.
*
* Returns: a pointer to the QEMUTimerList created
*/
QEMUTimerList *timerlist_new(QEMUClockType type,
QEMUTimerListNotifyCB *cb, void *opaque);
/**
* timerlist_has_timers:
* @timer_list: the timer list to operate on
*
* Determine whether a timer list has active timers
*
* Note that this function should not be used when other threads also access
* the timer list. The return value may be outdated by the time it is acted
* upon.
*
* Returns: true if the timer list has timers.
*/
bool timerlist_has_timers(QEMUTimerList *timer_list);
/**
* timerlist_expired:
* @timer_list: the timer list to operate on
*
* Determine whether a timer list has any timers which
* are expired.
*
* Returns: true if the timer list has timers which
* have expired.
*/
bool timerlist_expired(QEMUTimerList *timer_list);
/**
* timerlist_deadline_ns:
* @timer_list: the timer list to operate on
*
* Determine the deadline for a timer_list, i.e.
* the number of nanoseconds until the first timer
* expires. Return -1 if there are no timers.
*
* Returns: the number of nanoseconds until the earliest
* timer expires -1 if none
*/
int64_t timerlist_deadline_ns(QEMUTimerList *timer_list);
/**
* timerlist_get_clock:
* @timer_list: the timer list to operate on
*
* Determine the clock type associated with a timer list.
*
* Returns: the clock type associated with the
* timer list.
*/
QEMUClockType timerlist_get_clock(QEMUTimerList *timer_list);
/**
* timerlist_run_timers:
* @timer_list: the timer list to use
*
* Call all expired timers associated with the timer list.
*
* Returns: true if any timer expired
*/
bool timerlist_run_timers(QEMUTimerList *timer_list);
/**
* timerlist_notify:
* @timer_list: the timer list to use
*
* call the notifier callback associated with the timer list.
*/
void timerlist_notify(QEMUTimerList *timer_list);
/*
* QEMUTimerListGroup
*/
/**
* timerlistgroup_init:
* @tlg: the timer list group
* @cb: the callback to call when a notify is required
* @opaque: the opaque pointer to be passed to the callback.
*
* Initialise a timer list group. This must already be
* allocated in memory and zeroed. The notifier callback is
* called whenever a clock in the timer list group is
* reenabled or whenever a timer associated with any timer
* list is modified. If @cb is specified as null, qemu_notify()
* is used instead.
*/
void timerlistgroup_init(QEMUTimerListGroup *tlg,
QEMUTimerListNotifyCB *cb, void *opaque);
/**
* timerlistgroup_deinit:
* @tlg: the timer list group
*
* Deinitialise a timer list group. This must already be
* initialised. Note the memory is not freed.
*/
void timerlistgroup_deinit(QEMUTimerListGroup *tlg);
/**
* timerlistgroup_run_timers:
* @tlg: the timer list group
*
* Run the timers associated with a timer list group.
* This will run timers on multiple clocks.
*
* Returns: true if any timer callback ran
*/
bool timerlistgroup_run_timers(QEMUTimerListGroup *tlg);
/**
* timerlistgroup_deadline_ns:
* @tlg: the timer list group
*
* Determine the deadline of the soonest timer to
* expire associated with any timer list linked to
* the timer list group. Only clocks suitable for
* deadline calculation are included.
*
* Returns: the deadline in nanoseconds or -1 if no
* timers are to expire.
*/
int64_t timerlistgroup_deadline_ns(QEMUTimerListGroup *tlg);
/*
* QEMUTimer
*/
/**
* timer_init:
* @ts: the timer to be initialised
* @timer_list: the timer list to attach the timer to
* @scale: the scale value for the timer
* @cb: the callback to be called when the timer expires
* @opaque: the opaque pointer to be passed to the callback
*
* Initialise a new timer and associate it with @timer_list.
* The caller is responsible for allocating the memory.
*
* You need not call an explicit deinit call. Simply make
* sure it is not on a list with timer_del.
*/
void timer_init(QEMUTimer *ts,
QEMUTimerList *timer_list, int scale,
QEMUTimerCB *cb, void *opaque);
/**
* timer_new_tl:
* @timer_list: the timer list to attach the timer to
* @scale: the scale value for the timer
* @cb: the callback to be called when the timer expires
* @opaque: the opaque pointer to be passed to the callback
*
* Creeate a new timer and associate it with @timer_list.
* The memory is allocated by the function.
*
* This is not the preferred interface unless you know you
* are going to call timer_free. Use timer_init instead.
*
* Returns: a pointer to the timer
*/
static inline QEMUTimer *timer_new_tl(QEMUTimerList *timer_list,
int scale,
QEMUTimerCB *cb,
void *opaque)
{
QEMUTimer *ts = g_malloc0(sizeof(QEMUTimer));
timer_init(ts, timer_list, scale, cb, opaque);
return ts;
}
/**
* timer_free:
* @ts: the timer
*
* Free a timer (it must not be on the active list)
*/
void timer_free(QEMUTimer *ts);
/**
* timer_del:
* @ts: the timer
*
* Delete a timer from the active list.
*
* This function is thread-safe but the timer and its timer list must not be
* freed while this function is running.
*/
void timer_del(QEMUTimer *ts);
/**
* timer_mod_ns:
* @ts: the timer
* @expire_time: the expiry time in nanoseconds
*
* Modify a timer to expire at @expire_time
*
* This function is thread-safe but the timer and its timer list must not be
* freed while this function is running.
*/
void timer_mod_ns(QEMUTimer *ts, int64_t expire_time);
/**
* timer_mod_anticipate_ns:
* @ts: the timer
* @expire_time: the expiry time in nanoseconds
*
* Modify a timer to expire at @expire_time or the current time,
* whichever comes earlier.
*
* This function is thread-safe but the timer and its timer list must not be
* freed while this function is running.
*/
void timer_mod_anticipate_ns(QEMUTimer *ts, int64_t expire_time);
/**
* timer_mod:
* @ts: the timer
* @expire_time: the expire time in the units associated with the timer
*
* Modify a timer to expiry at @expire_time, taking into
* account the scale associated with the timer.
*
* This function is thread-safe but the timer and its timer list must not be
* freed while this function is running.
*/
void timer_mod(QEMUTimer *ts, int64_t expire_timer);
/**
* timer_mod_anticipate:
* @ts: the timer
* @expire_time: the expiry time in nanoseconds
*
* Modify a timer to expire at @expire_time or the current time, whichever
* comes earlier, taking into account the scale associated with the timer.
*
* This function is thread-safe but the timer and its timer list must not be
* freed while this function is running.
*/
void timer_mod_anticipate(QEMUTimer *ts, int64_t expire_time);
/**
* timer_pending:
* @ts: the timer
*
* Determines whether a timer is pending (i.e. is on the
* active list of timers, whether or not it has not yet expired).
*
* Returns: true if the timer is pending
*/
bool timer_pending(QEMUTimer *ts);
/**
* timer_expired:
* @ts: the timer
*
* Determines whether a timer has expired.
*
* Returns: true if the timer has expired
*/
bool timer_expired(QEMUTimer *timer_head, int64_t current_time);
/**
* timer_expire_time_ns:
* @ts: the timer
*
* Determine the expiry time of a timer
*
* Returns: the expiry time in nanoseconds
*/
uint64_t timer_expire_time_ns(QEMUTimer *ts);
/**
* timer_get:
* @f: the file
* @ts: the timer
*
* Read a timer @ts from a file @f
*/
void timer_get(QEMUFile *f, QEMUTimer *ts);
/**
* timer_put:
* @f: the file
* @ts: the timer
*/
void timer_put(QEMUFile *f, QEMUTimer *ts);
/*
* General utility functions
*/
/**
* qemu_timeout_ns_to_ms:
* @ns: nanosecond timeout value