From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PULL 07/13] monitor: Reduce casting of QAPI event QDict
Date: Tue, 27 Oct 2015 10:21:41 +0100 [thread overview]
Message-ID: <1445937707-22768-8-git-send-email-armbru@redhat.com> (raw)
In-Reply-To: <1445937707-22768-1-git-send-email-armbru@redhat.com>
Make the variables holding the event QDict instead of QObject.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <1444921716-9511-2-git-send-email-armbru@redhat.com>
---
monitor.c | 38 +++++++++++++++++++-------------------
1 file changed, 19 insertions(+), 19 deletions(-)
diff --git a/monitor.c b/monitor.c
index 301a143..f90a42f 100644
--- a/monitor.c
+++ b/monitor.c
@@ -185,7 +185,7 @@ typedef struct MonitorQAPIEventState {
int64_t rate; /* Minimum time (in ns) between two events */
int64_t last; /* QEMU_CLOCK_REALTIME value at last emission */
QEMUTimer *timer; /* Timer for handling delayed events */
- QObject *data; /* Event pending delayed dispatch */
+ QDict *qdict; /* Delayed event (if any) */
} MonitorQAPIEventState;
struct Monitor {
@@ -444,14 +444,14 @@ static MonitorQAPIEventState monitor_qapi_event_state[QAPI_EVENT_MAX];
* Emits the event to every monitor instance, @event is only used for trace
* Called with monitor_lock held.
*/
-static void monitor_qapi_event_emit(QAPIEvent event, QObject *data)
+static void monitor_qapi_event_emit(QAPIEvent event, QDict *qdict)
{
Monitor *mon;
- trace_monitor_protocol_event_emit(event, data);
+ trace_monitor_protocol_event_emit(event, qdict);
QLIST_FOREACH(mon, &mon_list, entry) {
if (monitor_is_qmp(mon) && mon->qmp.in_command_mode) {
- monitor_json_emitter(mon, data);
+ monitor_json_emitter(mon, QOBJECT(qdict));
}
}
}
@@ -461,7 +461,7 @@ static void monitor_qapi_event_emit(QAPIEvent event, QObject *data)
* applying any rate limiting if required.
*/
static void
-monitor_qapi_event_queue(QAPIEvent event, QDict *data, Error **errp)
+monitor_qapi_event_queue(QAPIEvent event, QDict *qdict, Error **errp)
{
MonitorQAPIEventState *evstate;
assert(event < QAPI_EVENT_MAX);
@@ -469,7 +469,7 @@ monitor_qapi_event_queue(QAPIEvent event, QDict *data, Error **errp)
evstate = &(monitor_qapi_event_state[event]);
trace_monitor_protocol_event_queue(event,
- data,
+ qdict,
evstate->rate,
evstate->last,
now);
@@ -477,26 +477,26 @@ monitor_qapi_event_queue(QAPIEvent event, QDict *data, Error **errp)
/* Rate limit of 0 indicates no throttling */
qemu_mutex_lock(&monitor_lock);
if (!evstate->rate) {
- monitor_qapi_event_emit(event, QOBJECT(data));
+ monitor_qapi_event_emit(event, qdict);
evstate->last = now;
} else {
int64_t delta = now - evstate->last;
- if (evstate->data ||
+ if (evstate->qdict ||
delta < evstate->rate) {
/* If there's an existing event pending, replace
* it with the new event, otherwise schedule a
* timer for delayed emission
*/
- if (evstate->data) {
- qobject_decref(evstate->data);
+ if (evstate->qdict) {
+ QDECREF(evstate->qdict);
} else {
int64_t then = evstate->last + evstate->rate;
timer_mod_ns(evstate->timer, then);
}
- evstate->data = QOBJECT(data);
- qobject_incref(evstate->data);
+ evstate->qdict = qdict;
+ QINCREF(evstate->qdict);
} else {
- monitor_qapi_event_emit(event, QOBJECT(data));
+ monitor_qapi_event_emit(event, qdict);
evstate->last = now;
}
}
@@ -513,14 +513,14 @@ static void monitor_qapi_event_handler(void *opaque)
int64_t now = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
trace_monitor_protocol_event_handler(evstate->event,
- evstate->data,
+ evstate->qdict,
evstate->last,
now);
qemu_mutex_lock(&monitor_lock);
- if (evstate->data) {
- monitor_qapi_event_emit(evstate->event, evstate->data);
- qobject_decref(evstate->data);
- evstate->data = NULL;
+ if (evstate->qdict) {
+ monitor_qapi_event_emit(evstate->event, evstate->qdict);
+ QDECREF(evstate->qdict);
+ evstate->qdict = NULL;
}
evstate->last = now;
qemu_mutex_unlock(&monitor_lock);
@@ -547,7 +547,7 @@ monitor_qapi_event_throttle(QAPIEvent event, int64_t rate)
assert(rate * SCALE_MS <= INT64_MAX);
evstate->rate = rate * SCALE_MS;
evstate->last = 0;
- evstate->data = NULL;
+ evstate->qdict = NULL;
evstate->timer = timer_new(QEMU_CLOCK_REALTIME,
SCALE_MS,
monitor_qapi_event_handler,
--
2.4.3
next prev parent reply other threads:[~2015-10-27 9:21 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-27 9:21 [Qemu-devel] [PULL 00/13] QMP and QObject patches Markus Armbruster
2015-10-27 9:21 ` [Qemu-devel] [PULL 01/13] qobject: Drop QObject_HEAD Markus Armbruster
2015-10-27 9:21 ` [Qemu-devel] [PULL 02/13] qbool: Make conversion from QObject * accept null Markus Armbruster
2015-10-27 9:21 ` [Qemu-devel] [PULL 03/13] qdict: " Markus Armbruster
2015-10-27 9:21 ` [Qemu-devel] [PULL 04/13] qfloat qint: " Markus Armbruster
2015-10-27 9:21 ` [Qemu-devel] [PULL 05/13] qlist: " Markus Armbruster
2015-10-27 9:21 ` [Qemu-devel] [PULL 06/13] qstring: " Markus Armbruster
2015-10-27 9:21 ` Markus Armbruster [this message]
2015-10-27 9:21 ` [Qemu-devel] [PULL 08/13] monitor: Simplify event throttling Markus Armbruster
2015-10-27 9:21 ` [Qemu-devel] [PULL 09/13] monitor: Switch from timer_new() to timer_new_ns() Markus Armbruster
2015-10-27 9:21 ` [Qemu-devel] [PULL 10/13] monitor: Split MonitorQAPIEventConf off MonitorQAPIEventState Markus Armbruster
2015-10-27 9:21 ` [Qemu-devel] [PULL 11/13] monitor: Turn monitor_qapi_event_state[] into a hash table Markus Armbruster
2015-10-27 9:21 ` [Qemu-devel] [PULL 12/13] monitor: Throttle event VSERPORT_CHANGE separately by "id" Markus Armbruster
2015-10-27 9:21 ` [Qemu-devel] [PULL 13/13] docs: Document QMP event rate limiting Markus Armbruster
2015-10-27 13:06 ` [Qemu-devel] [PULL 00/13] QMP and QObject patches Peter Maydell
2015-10-27 14:28 ` Markus Armbruster
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1445937707-22768-8-git-send-email-armbru@redhat.com \
--to=armbru@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).