Skip to content
  • Daniel P. Berrangé's avatar
    dbb44504
    io: add qio_task_wait_thread to join with a background thread · dbb44504
    Daniel P. Berrangé authored
    
    
    Add the ability for a caller to wait for completion of the
    background thread to synchronously dispatch its result, without
    needing to wait for the main loop to run the idle callback.
    
    This method needs very careful usage to avoid a dangerous
    race condition with the free'ing of the task. The completion
    callback is normally invoked from an idle callback registered
    with the main loop context. The qio_task_wait_thread method
    must only be called if the completion callback has not yet
    run. The only safe way to achieve this is to run the
    qio_task_wait_thread method from the thread that executes
    the main loop.
    
    It is generally a bad idea to use this method since it will
    block execution of the main loop, however, the design of
    the character devices and its usage from vhostuser already
    requires blocking execution.
    
    Signed-off-by: default avatarDaniel P. Berrangé <berrange@redhat.com>
    Message-Id: <20190211182442.8542-3-berrange@redhat.com>
    Signed-off-by: default avatarMarc-André Lureau <marcandre.lureau@redhat.com>
    dbb44504
    io: add qio_task_wait_thread to join with a background thread
    Daniel P. Berrangé authored
    
    
    Add the ability for a caller to wait for completion of the
    background thread to synchronously dispatch its result, without
    needing to wait for the main loop to run the idle callback.
    
    This method needs very careful usage to avoid a dangerous
    race condition with the free'ing of the task. The completion
    callback is normally invoked from an idle callback registered
    with the main loop context. The qio_task_wait_thread method
    must only be called if the completion callback has not yet
    run. The only safe way to achieve this is to run the
    qio_task_wait_thread method from the thread that executes
    the main loop.
    
    It is generally a bad idea to use this method since it will
    block execution of the main loop, however, the design of
    the character devices and its usage from vhostuser already
    requires blocking execution.
    
    Signed-off-by: default avatarDaniel P. Berrangé <berrange@redhat.com>
    Message-Id: <20190211182442.8542-3-berrange@redhat.com>
    Signed-off-by: default avatarMarc-André Lureau <marcandre.lureau@redhat.com>
Loading