dbus-c++: Add support for deferred object registration.
This allows us to avoid a nasty antipattern caused by inability to register
objects from a signal handler (which ordinarily causes a deadlock as we reenter
the dispatch loop in dbus-c++).
BUG=chromium-os:11752
TEST=Adhoc
Change-Id: Ic6a92b5ee706988206ccd0603da776fb2c9685ce
Signed-off-by: Elly Jones <[email protected]>
Reviewed-on: http://gerrit.chromium.org/gerrit/1649
Reviewed-by: Jason Glasgow <[email protected]>
diff --git a/include/dbus-c++/object.h b/include/dbus-c++/object.h
index 4e8ea6d..ca9ca7d 100644
--- a/include/dbus-c++/object.h
+++ b/include/dbus-c++/object.h
@@ -117,7 +117,13 @@
struct Private;
+ enum registration_time {
+ REGISTER_NOW,
+ REGISTER_LATER,
+ };
+
ObjectAdaptor(Connection &conn, const Path &path);
+ ObjectAdaptor(Connection &conn, const Path &path, registration_time rtime);
~ObjectAdaptor();
diff --git a/src/object.cpp b/src/object.cpp
index 5bb538d..26ce74e 100644
--- a/src/object.cpp
+++ b/src/object.cpp
@@ -154,6 +154,13 @@
register_obj();
}
+ObjectAdaptor::ObjectAdaptor(Connection &conn, const Path &path, registration_time rtime)
+: Object(conn, path, conn.unique_name())
+{
+ if (rtime == REGISTER_NOW)
+ register_obj();
+}
+
ObjectAdaptor::~ObjectAdaptor()
{
unregister_obj();