From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56874) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWs22-0005FG-PP for qemu-devel@nongnu.org; Tue, 01 Sep 2015 16:19:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZWs1y-0003ik-ON for qemu-devel@nongnu.org; Tue, 01 Sep 2015 16:19:50 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36526) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWs1y-0003iR-Gs for qemu-devel@nongnu.org; Tue, 01 Sep 2015 16:19:46 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id D5A098EA2F for ; Tue, 1 Sep 2015 20:19:45 +0000 (UTC) References: <1439408763-12785-1-git-send-email-marcandre.lureau@redhat.com> <1439408763-12785-2-git-send-email-marcandre.lureau@redhat.com> From: Eric Blake Message-ID: <55E6085C.3060607@redhat.com> Date: Tue, 1 Sep 2015 14:19:40 -0600 MIME-Version: 1.0 In-Reply-To: <1439408763-12785-2-git-send-email-marcandre.lureau@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="6mgX69FTB3aT7V601x3e4SihGmqbea4Ti" Subject: Re: [Qemu-devel] [RFC 1/3] monitor: split MonitorQAPIEventState List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: marcandre.lureau@redhat.com, qemu-devel@nongnu.org Cc: lersek@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --6mgX69FTB3aT7V601x3e4SihGmqbea4Ti Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 08/12/2015 01:46 PM, marcandre.lureau@redhat.com wrote: > From: Marc-Andr=C3=A9 Lureau >=20 > Create a seperate pending event structure MonitorQAPIEventPending. s/seperate/separate/ > Use a MonitorQAPIEventDelay callback to handle the delaying. This > allows other implementations of throttling. >=20 > Signed-off-by: Marc-Andr=C3=A9 Lureau > --- > monitor.c | 124 +++++++++++++++++++++++++++++++++++++--------------= -------- > trace-events | 2 +- > 2 files changed, 79 insertions(+), 47 deletions(-) >=20 > =20 > +typedef struct MonitorQAPIEventPending { > + QAPIEvent event; /* Event being tracked */ > + int64_t last; /* QEMU_CLOCK_REALTIME value at last emission = */ > + QEMUTimer *timer; /* Timer for handling delayed events */ > + QObject *data; /* Event pending delayed dispatch */ > +} MonitorQAPIEventPending; > + > +typedef struct MonitorQAPIEventState MonitorQAPIEventState; Some places combine the typedef with the struct definition; I'm not sure there's any hard and fast rule, though. (HACKING mentions that we want the typedef, but doesn't give guidelines on how it must be provided). > +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 */ > -} MonitorQAPIEventState; > + MonitorQAPIEventDelay delay; > + gpointer data; Do we really need 'gpointer', or is 'void *' sufficient? > =20 > +static bool > +monitor_qapi_event_delay(MonitorQAPIEventState *evstate, QDict *data) > +{ > + int64_t now =3D qemu_clock_get_ns(QEMU_CLOCK_REALTIME); > + MonitorQAPIEventPending *p =3D evstate->data; > + int64_t delta =3D now - p->last; > + > + /* Rate limit of 0 indicates no throttling */ > + if (!evstate->rate) { > + p->last =3D now; > + return FALSE; s/FALSE/false/ (we want to directly use the C99 'bool' type here, not the glib macros that expand to who-knows-what-type followed by implicit conversion back to bool). > + p->data =3D QOBJECT(data); > + qobject_incref(p->data); > + return TRUE; > + } > + > + p->last =3D now; > + return FALSE; two more ALL_CAPS to convert to the lower bool counterpart. Otherwise looks like a sane split. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --6mgX69FTB3aT7V601x3e4SihGmqbea4Ti Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJV5ghcAAoJEKeha0olJ0Nq1JcIAKUjO5AU5w7KZp0kseXIz6u2 HVhq+gJI8nOJMyO+Cvelfo3ZCuzR4FiL0piGiXQ497nBs5/WyFStcumVZST1PXai KejfqEM6wFD7Eb++oShJjDWGjMzvHvL1p4b7/iY9g9ztJ/VLjlpb1UvTi35RyVWt sCIgdXlTM0t1SpkMr+Sb6muwrzV/Y0synBnv4IC88DF+fOC3Y6j6X0K4PrEzMLKm lrGjUZgy5Sl4k9frTd8D2oGsswBZ1Xt/2f9qfUjr6A1wkNDQuGRxe02GLtwrM5pD G+8eSjvXrsjMZkkutAACzQjLuzV5M+yJ6H4Cs/DOKAq/WHKtV2VX8YNzhQFtKv0= =OVYh -----END PGP SIGNATURE----- --6mgX69FTB3aT7V601x3e4SihGmqbea4Ti--