mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 21:55:25 +00:00
vireventthread: Introduce virEventThreadStop
The aim is to move parts of vir_event_thread_finalize() that MAY block into a separate function, so that unrefing the a virEventThread no longer blocks (or require releasing and subsequent re-acquiring of a mutex). Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
parent
bec195607c
commit
7aca235d8d
@ -2288,6 +2288,7 @@ virEventGLibRunOnce;
|
|||||||
# util/vireventthread.h
|
# util/vireventthread.h
|
||||||
virEventThreadGetContext;
|
virEventThreadGetContext;
|
||||||
virEventThreadNew;
|
virEventThreadNew;
|
||||||
|
virEventThreadStop;
|
||||||
|
|
||||||
|
|
||||||
# util/virfcp.h
|
# util/virfcp.h
|
||||||
|
@ -188,6 +188,28 @@ virEventThreadNew(const char *name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* virEventThreadStop:
|
||||||
|
* @evt: event thread
|
||||||
|
*
|
||||||
|
* May block until all events are processed. Typical use case is:
|
||||||
|
*
|
||||||
|
* virEventThread *evt = virEventThreadNew("name");
|
||||||
|
* ...
|
||||||
|
* virEventThreadStop(evt);
|
||||||
|
* g_object_unref(evt);
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
virEventThreadStop(virEventThread *evt)
|
||||||
|
{
|
||||||
|
if (evt->thread) {
|
||||||
|
g_main_loop_quit(evt->loop);
|
||||||
|
g_thread_join(evt->thread);
|
||||||
|
evt->thread = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
GMainContext *
|
GMainContext *
|
||||||
virEventThreadGetContext(virEventThread *evt)
|
virEventThreadGetContext(virEventThread *evt)
|
||||||
{
|
{
|
||||||
|
@ -28,4 +28,6 @@ G_DECLARE_FINAL_TYPE(virEventThread, vir_event_thread, VIR, EVENT_THREAD, GObjec
|
|||||||
|
|
||||||
virEventThread *virEventThreadNew(const char *name);
|
virEventThread *virEventThreadNew(const char *name);
|
||||||
|
|
||||||
|
void virEventThreadStop(virEventThread *evt);
|
||||||
|
|
||||||
GMainContext *virEventThreadGetContext(virEventThread *evt);
|
GMainContext *virEventThreadGetContext(virEventThread *evt);
|
||||||
|
Loading…
Reference in New Issue
Block a user