dbus_connection_set_wakeup_main_function
Havoc Pennington
havoc.pennington at gmail.com
Wed Feb 4 20:00:34 PST 2009
Hi,
On Wed, Feb 4, 2009 at 4:44 PM, Robert Greenwalt <rgreenwalt at google.com> wrote:
> the comment: "This function is responsible for waking up the main loop when
> some change has happened to the connection that the mainloop needs to
> reconsider" it sounded perfect. Call me when I need to do stuff and I'll do
> stuff (non-polled used of read_write_dispatch).
This is a misinterpretation of the wakeup main function; it's called
when the main loop may be blocked, and needs to wake up, because it
needs to change the set of things it's blocking on. Said set of things
would be the watches and timeouts. So basically wakeup main is called
when there are new watches or timeouts added. The problem this solves
is that if the main loop is blocking in one thread, and a watch or
timeout is added in another thread, the blocking main loop would not
know about the new watch or timeout.
The basic point of the API is so GLib can set the wakeup main function
to g_main_context_wakeup(). In theory other main loop APIs would need
a similar thing.
http://library.gnome.org/devel/glib/stable/glib-The-Main-Event-Loop.html#g-main-context-wakeup
Anyway, bottom line, mainloops are hard to write; that's why people
use GLib and Qt and whatever.
Havoc
More information about the dbus
mailing list