timer: add timer_mod_anticipate and timer_mod_anticipate_ns
These let a user anticipate the deadline of a timer, atomically with other sites that call the function. This helps avoiding complicated lock hierarchies. Reviewed-by: Alex Bligh <alex@alex.org.uk> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
@@ -544,6 +544,19 @@ void timer_del(QEMUTimer *ts);
|
||||
*/
|
||||
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
|
||||
@@ -557,6 +570,19 @@ void timer_mod_ns(QEMUTimer *ts, int64_t expire_time);
|
||||
*/
|
||||
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
|
||||
|
Reference in New Issue
Block a user