GDBusWorker: combine num_writes_pending with flush_pending
authorSimon McVittie <simon.mcvittie@collabora.co.uk>
Tue, 13 Sep 2011 16:37:33 +0000 (17:37 +0100)
committerDavid Zeuthen <davidz@redhat.com>
Fri, 16 Sep 2011 16:00:22 +0000 (12:00 -0400)
commita8f75f21b4b2264b385022496c597573ecb709da
tree05ab6b6c139aa5f05e054c896161732b62a574e1
parent05ef173466e32d8b3d212803e4a72239913a362d
GDBusWorker: combine num_writes_pending with flush_pending

num_writes_pending was a counter, but it only took values 0 or 1, so make
it a boolean: it would never make sense to be trying to write out two
messages at the same time (they'd get interleaved).

Similarly, we can never be writing and flushing at the same time (that'd
mean we were flushing halfway through a message, which would be pointless)
so combine it with flush_pending too, calling the result output_pending.

Also assert that it takes the expected value whenever we change it,
and document the locking discipline used for it, including a subtle
case in write_message_in_idle_cb where it's not obvious at first glance
why we don't need the lock.

(Having the combined boolean at the top of the block of write-related
struct members improves struct packing on 64-bit platforms, by packing
read_num_ancillary_messages and output_pending into one word.)

Bug: https://bugzilla.gnome.org/show_bug.cgi?id=651268
Bug-NB: NB#271520
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Signed-off-by: David Zeuthen <davidz@redhat.com>
gio/gdbusprivate.c