summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2011-01-24 14:38:13 +0000
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2011-06-13 16:28:06 +0100
commit5bd605616966bb1de148dd2c09b3b353c87076ec (patch)
tree2a78a04e00b620315c18d22cd9a242c0a76eaf4b
parent0292b1a56d15759cb2d485b6134a332b20594a2e (diff)
DBusLoop: inline add_callback, remove_callback into their callers
The watch and timeout code paths will diverge completely when we change WatchCallback * to just be a DBusWatch *, removing the benefit of having common code. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=33342 Reviewed-by: Thiago Macieira <thiago@kde.org>
-rw-r--r--dbus/dbus-mainloop.c72
1 files changed, 21 insertions, 51 deletions
diff --git a/dbus/dbus-mainloop.c b/dbus/dbus-mainloop.c
index 8ce00a3c..d597e1c6 100644
--- a/dbus/dbus-mainloop.c
+++ b/dbus/dbus-mainloop.c
@@ -181,52 +181,6 @@ callback_unref (Callback *cb)
}
}
-static dbus_bool_t
-add_callback (DBusLoop *loop,
- DBusList **list,
- Callback *cb)
-{
-
- if (!_dbus_list_append (list, cb))
- return FALSE;
-
- loop->callback_list_serial += 1;
-
- switch (cb->type)
- {
- case CALLBACK_WATCH:
- loop->watch_count += 1;
- break;
- case CALLBACK_TIMEOUT:
- loop->timeout_count += 1;
- break;
- }
-
- return TRUE;
-}
-
-static void
-remove_callback (DBusLoop *loop,
- DBusList **list,
- DBusList *link)
-{
- Callback *cb = link->data;
-
- switch (cb->type)
- {
- case CALLBACK_WATCH:
- loop->watch_count -= 1;
- break;
- case CALLBACK_TIMEOUT:
- loop->timeout_count -= 1;
- break;
- }
-
- callback_unref (cb);
- _dbus_list_remove_link (list, link);
- loop->callback_list_serial += 1;
-}
-
DBusLoop*
_dbus_loop_new (void)
{
@@ -282,7 +236,12 @@ _dbus_loop_add_watch (DBusLoop *loop,
if (wcb == NULL)
return FALSE;
- if (!add_callback (loop, &loop->watches, (Callback*) wcb))
+ if (_dbus_list_append (&loop->watches, wcb))
+ {
+ loop->callback_list_serial += 1;
+ loop->watch_count += 1;
+ }
+ else
{
callback_unref ((Callback*) wcb);
return FALSE;
@@ -311,7 +270,10 @@ _dbus_loop_remove_watch (DBusLoop *loop,
if (this->watch == watch)
{
- remove_callback (loop, &loop->watches, link);
+ _dbus_list_remove_link (&loop->watches, link);
+ loop->callback_list_serial += 1;
+ loop->watch_count -= 1;
+ callback_unref ((Callback *) this);
return;
}
@@ -332,7 +294,12 @@ _dbus_loop_add_timeout (DBusLoop *loop,
if (tcb == NULL)
return FALSE;
- if (!add_callback (loop, &loop->timeouts, (Callback*) tcb))
+ if (_dbus_list_append (&loop->timeouts, tcb))
+ {
+ loop->callback_list_serial += 1;
+ loop->timeout_count += 1;
+ }
+ else
{
callback_unref ((Callback*) tcb);
return FALSE;
@@ -357,8 +324,11 @@ _dbus_loop_remove_timeout (DBusLoop *loop,
if (this->timeout == timeout)
{
- remove_callback (loop, &loop->timeouts, link);
-
+ _dbus_list_remove_link (&loop->timeouts, link);
+ loop->callback_list_serial += 1;
+ loop->timeout_count -= 1;
+ callback_unref ((Callback *) this);
+
return;
}