[patch] Add a level of abstraction to condvars and mutexes so we can initalize them late

John (J5) Palmieri johnp at redhat.com
Wed Aug 16 11:31:47 PDT 2006


On Wed, 2006-08-16 at 14:17 -0400, Havoc Pennington wrote:

> >> +void
> >> +_dbus_mutex_new_at_location (DBusMutex **location_p)
> >> +{
> >> +  _dbus_assert (location_p != NULL);
> >> +
> >> +  *location_p = _dbus_mutex_new();
> >> +
> >> +  if (thread_init_generation == 0 && *location_p)
> >> +    {
> >> +      if (!_dbus_list_append (&uninitialized_mutex_list, location_p))
> >> +        {
> >> +	  _dbus_mutex_free (*location_p);
> >> +	  *location_p = NULL;
> >> +	}
> >> +    }
> >> +}

> This will need to return bool for whether it ran out of memory.

*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? 

> 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.

-- 
John (J5) Palmieri <johnp at redhat.com>



More information about the dbus mailing list