Merge remote-tracking branch 'remotes/vivier2/tags/linux-user-for-4.1-pull-request...
[qemu/ar7.git] / include / sysemu / iothread.h
blob5f6240d5cb7fcb605071bfa00a430e6159e47f75
1 /*
2 * Event loop thread
4 * Copyright Red Hat Inc., 2013
6 * Authors:
7 * Stefan Hajnoczi <stefanha@redhat.com>
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.
14 #ifndef IOTHREAD_H
15 #define IOTHREAD_H
17 #include "block/aio.h"
18 #include "qemu/thread.h"
20 #define TYPE_IOTHREAD "iothread"
22 typedef struct {
23 Object parent_obj;
25 QemuThread thread;
26 AioContext *ctx;
27 bool run_gcontext; /* whether we should run gcontext */
28 GMainContext *worker_context;
29 GMainLoop *main_loop;
30 QemuSemaphore init_done_sem; /* is thread init done? */
31 bool stopping; /* has iothread_stop() been called? */
32 bool running; /* should iothread_run() continue? */
33 int thread_id;
35 /* AioContext poll parameters */
36 int64_t poll_max_ns;
37 int64_t poll_grow;
38 int64_t poll_shrink;
39 } IOThread;
41 #define IOTHREAD(obj) \
42 OBJECT_CHECK(IOThread, obj, TYPE_IOTHREAD)
44 char *iothread_get_id(IOThread *iothread);
45 IOThread *iothread_by_id(const char *id);
46 AioContext *iothread_get_aio_context(IOThread *iothread);
47 GMainContext *iothread_get_g_main_context(IOThread *iothread);
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".
54 IOThread *iothread_create(const char *id, Error **errp);
55 void iothread_stop(IOThread *iothread);
56 void iothread_destroy(IOThread *iothread);
58 #endif /* IOTHREAD_H */