/** * fluid_hashtable_ref: * @hashtable: a valid #fluid_hashtable_t. * * Atomically increments the reference count of @hashtable by one. * This function is MT-safe and may be called from any thread. * * Return value: the passed in #fluid_hashtable_t. * * Since: 2.10 **/ fluid_hashtable_t* fluid_hashtable_ref (fluid_hashtable_t *hashtable) { fluid_return_val_if_fail (hashtable != NULL, NULL); fluid_return_val_if_fail (hashtable->ref_count > 0, hashtable); fluid_atomic_int_add (&hashtable->ref_count, 1); return hashtable; }
/* Unref a tuning object, when it reaches 0 it is deleted, returns TRUE if deleted */ int fluid_tuning_unref (fluid_tuning_t *tuning, int count) { fluid_return_val_if_fail (tuning != NULL, FALSE); /* Add and compare are separate, but that is OK, since refcount will only * reach 0 when there are no references and therefore no possibility of * another thread adding a reference in between */ fluid_atomic_int_add (&tuning->refcount, -count); /* Delete when refcount reaches 0 */ if (!fluid_atomic_int_get (&tuning->refcount)) { delete_fluid_tuning (tuning); return TRUE; } else return FALSE; }