]> git.proxmox.com Git - mirror_qemu.git/blame - include/sysemu/iothread.h
iothread: provide helpers for internal use
[mirror_qemu.git] / include / sysemu / iothread.h
CommitLineData
be8d8537
SH
1/*
2 * Event loop thread
3 *
4 * Copyright Red Hat Inc., 2013
5 *
6 * Authors:
7 * Stefan Hajnoczi <stefanha@redhat.com>
8 *
9 * This work is licensed under the terms of the GNU GPL, version 2 or later.
10 * See the COPYING file in the top-level directory.
11 *
12 */
13
14#ifndef IOTHREAD_H
15#define IOTHREAD_H
16
17#include "block/aio.h"
8c2664d8 18#include "qemu/thread.h"
be8d8537
SH
19
20#define TYPE_IOTHREAD "iothread"
21
8c2664d8
SH
22typedef struct {
23 Object parent_obj;
24
25 QemuThread thread;
26 AioContext *ctx;
329163cb
WY
27 GMainContext *worker_context;
28 GMainLoop *main_loop;
29 GOnce once;
8c2664d8
SH
30 QemuMutex init_done_lock;
31 QemuCond init_done_cond; /* is thread initialization done? */
32 bool stopping;
33 int thread_id;
0d9d86fb
SH
34
35 /* AioContext poll parameters */
36 int64_t poll_max_ns;
5e5db499
SH
37 int64_t poll_grow;
38 int64_t poll_shrink;
8c2664d8 39} IOThread;
be8d8537
SH
40
41#define IOTHREAD(obj) \
42 OBJECT_CHECK(IOThread, obj, TYPE_IOTHREAD)
43
be8d8537
SH
44char *iothread_get_id(IOThread *iothread);
45AioContext *iothread_get_aio_context(IOThread *iothread);
dce8921b 46void iothread_stop_all(void);
329163cb 47GMainContext *iothread_get_g_main_context(IOThread *iothread);
be8d8537 48
0173e21b
PX
49/*
50 * Helpers used to allocate iothreads for internal use. These
51 * iothreads will not be seen by monitor clients when query using
52 * "query-iothreads".
53 */
54IOThread *iothread_create(const char *id, Error **errp);
55void iothread_destroy(IOThread *iothread);
56
be8d8537 57#endif /* IOTHREAD_H */