On 17/04/2015 16:22, Daniel P. Berrange wrote: > 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. > > In this series, the QIOTask class will be used for things like > the TLS handshake, the websockets handshake and TCP connect() > progress.
Is this actually worth making it a heavyweight QOM object? In general if you don't do object_property_add_child (and I don't think here you do), it's simpler to just make it a C struct. In this case I even think you're leaking the task. You do object_ref twice (once at creation time, once before qio_channel_add_watch_full) and only have one object_unref. I would just do without reference counting, and add a qio_task_free() function that calls qio_task_finalize() and frees the QIOTask. BTW, do you have plans to use the GDestroyNotify argument to qio_task_new, or is it just for consistency? Paolo