mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-30 13:31:52 -06:00
util: add qemu-co-timeout
Add new API, to make a time limited call of the coroutine. Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@openvz.org> Reviewed-by: Hanna Reitz <hreitz@redhat.com> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
This commit is contained in:
parent
dd3e97dfbe
commit
e1878eb5f0
3 changed files with 103 additions and 0 deletions
|
@ -331,6 +331,19 @@ static inline void coroutine_fn qemu_co_sleep_ns(QEMUClockType type, int64_t ns)
|
|||
qemu_co_sleep_ns_wakeable(&w, type, ns);
|
||||
}
|
||||
|
||||
typedef void CleanupFunc(void *opaque);
|
||||
/**
|
||||
* Run entry in a coroutine and start timer. Wait for entry to finish or for
|
||||
* timer to elapse, what happen first. If entry finished, return 0, if timer
|
||||
* elapsed earlier, return -ETIMEDOUT.
|
||||
*
|
||||
* Be careful, entry execution is not canceled, user should handle it somehow.
|
||||
* If @clean is provided, it's called after coroutine finish if timeout
|
||||
* happened.
|
||||
*/
|
||||
int coroutine_fn qemu_co_timeout(CoroutineEntry *entry, void *opaque,
|
||||
uint64_t timeout_ns, CleanupFunc clean);
|
||||
|
||||
/**
|
||||
* Wake a coroutine if it is sleeping in qemu_co_sleep_ns. The timer will be
|
||||
* deleted. @sleep_state must be the variable whose address was given to
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue