dbus_g_thread_init()

Julien PUYDT julien.puydt at laposte.net
Wed Sep 13 09:36:51 PDT 2006


Havoc Pennington a écrit :
>> The idea is to have a public dbus_g_init(gboolean is_threaded) function.
>> Most libraries have an init function so this is fine and we need it
>> anyway since the type system is currently initialized by dbus_g_bus_get
>> and there are instances where you need to use dbus types before you get
>> a connection.
> 
> I think this is kind of a downgrade; init functions are in general evil 
> (I consider g_type_init() a design bug)
> 
> The thread init function exists for only two reasons:
>  - possible performance concerns
>  - dbus not having built-in thread primitives, so someone had to
>    provide the glib or qt ones
> 
> But it's deliberately an init function only for threading; there's 
> deliberately no generic dbus_init.

There are other problems with init functions :
- what if they're called several times ?
- what if they're called late ?

More specifically, if an application loads plugins, and those plugins 
use DBus :
- what happens if several of them initialize dbus ;
- what happens if my application already has several threads when those 
plugins kick in ?

There's also the case of using a library which uses dbus behind your 
back (doesn't avahi do that ?).

Ekiga will soon have parts of it coming in as plugins, so these 
threading questions really matter to me.

Snark on #ekiga


More information about the dbus mailing list