]> git.proxmox.com Git - mirror_qemu.git/commit - tests/Makefile.include
io: add QIOTask class for async operations
authorDaniel P. Berrange <berrange@redhat.com>
Wed, 18 Mar 2015 17:25:45 +0000 (17:25 +0000)
committerDaniel P. Berrange <berrange@redhat.com>
Fri, 18 Dec 2015 12:18:30 +0000 (12:18 +0000)
commitb02db2d9203ccfd1c26e55f7d975f0c05caee0ce
tree0fda9f2f8d4c39d9c44a6fcff16f64faac4aa7ca
parent1c809fa01df0c638417480dfd446415615bfd217
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>
include/io/task.h [new file with mode: 0644]
io/Makefile.objs
io/task.c [new file with mode: 0644]
tests/.gitignore
tests/Makefile
tests/test-io-task.c [new file with mode: 0644]
trace-events