mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 15:53:54 -06:00
io: add QIOTask class for async operations
A number of I/O operations need to be performed asynchronously to avoid blocking the main loop. The caller of such APIs need to provide a callback to be invoked on completion/error and need access to the error, if any. The small QIOTask provides a simple framework for dealing with such probes. The API docs inline provide an outline of how this is to be used. Some functions don't have the ability to run asynchronously (eg getaddrinfo always blocks), so to facilitate their use, the task class provides a mechanism to run a blocking function in a thread, while triggering the completion callback in the main event loop thread. This easily allows any synchronous function to be made asynchronous, albeit at the cost of spawning a thread. In this series, the QIOTask class will be used for things like the TLS handshake, the websockets handshake and TCP connect() progress. The concept of QIOTask is inspired by the GAsyncResult interface / GTask class in the GIO libraries. The min version requirements on glib don't allow those to be used from QEMU, so QIOTask provides a facsimilie which can be easily switched to GTask in the future if the min version is increased. Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
parent
1c809fa01d
commit
b02db2d920
7 changed files with 697 additions and 0 deletions
|
@ -1808,3 +1808,12 @@ user_handle_signal(void *env, int target_sig) "env=%p signal %d"
|
|||
user_host_signal(void *env, int host_sig, int target_sig) "env=%p signal %d (target %d("
|
||||
user_queue_signal(void *env, int target_sig) "env=%p signal %d"
|
||||
user_s390x_restore_sigregs(void *env, uint64_t sc_psw_addr, uint64_t env_psw_addr) "env=%p frame psw.addr "PRIx64 " current psw.addr "PRIx64""
|
||||
|
||||
# io/task.c
|
||||
qio_task_new(void *task, void *source, void *func, void *opaque) "Task new task=%p source=%p func=%p opaque=%p"
|
||||
qio_task_complete(void *task) "Task complete task=%p"
|
||||
qio_task_abort(void *task) "Task abort task=%p"
|
||||
qio_task_thread_start(void *task, void *worker, void *opaque) "Task thread start task=%p worker=%p opaque=%p"
|
||||
qio_task_thread_run(void *task) "Task thread run task=%p"
|
||||
qio_task_thread_exit(void *task) "Task thread exit task=%p"
|
||||
qio_task_thread_result(void *task) "Task thread result task=%p"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue