[patch] Add a level of abstraction to condvars and mutexes so
we can initalize them late
Havoc Pennington
hp at redhat.com
Wed Aug 16 11:37:32 PDT 2006
John (J5) Palmieri wrote:
> *location_p == NULL indicates OOM (as it does with _dbus_mutex_new). I
> can change this to returning a bool but isn't that superfluous or is the
> goal here to make it clearer to a developer?
>
Ah OK, that sounds fine, obvious in retrospect.
>> The test thread_init_generation == 0 should be
>> thread_init_generation != _dbus_current_generation instead, so multiple
>> generations can be used.
>
> Easy change but I don't understand what a generation is and how threads
> can be initialized more than once. Just for my knowledge can you give a
> brief explanation.
>
dbus can be shut down (completely uninitialized) with dbus_shutdown(),
at that point the generation is incremented and any of the init/setup
stuff can be used again.
Times when you might shut down:
- to help in memory leak tracking (e.g. the test suite relies on it)
- if you are using the library from a plugin and know the main app
isn't using it
The generation counter is used rather than a simple "bool initialized"
because it lets us detect more kinds of mistake, such as using a
connection after shutting down the generation that created it.
Havoc
More information about the dbus
mailing list