void kobj_class_uninstantiate(kobj_class_t cls) { lwkt_gettoken(&kobj_token); crit_enter(); cls->refs--; if (cls->refs == 0) kobj_class_free(cls); crit_exit(); lwkt_reltoken(&kobj_token); }
void kobj_delete(kobj_t obj, struct malloc_type *mtype) { kobj_class_t cls = obj->ops->cls; /* * Consider freeing the compiled method table for the class * after its last instance is deleted. As an optimisation, we * should defer this for a short while to avoid thrashing. */ cls->refs--; if (!cls->refs) kobj_class_free(cls); obj->ops = 0; if (mtype) free(obj, mtype); }
void kobj_delete(kobj_t obj, struct malloc_type *mtype) { kobj_class_t cls = obj->ops->cls; int refs; /* * Consider freeing the compiled method table for the class * after its last instance is deleted. As an optimisation, we * should defer this for a short while to avoid thrashing. */ KOBJ_ASSERT(MA_NOTOWNED); KOBJ_LOCK(); cls->refs--; refs = cls->refs; KOBJ_UNLOCK(); if (!refs) kobj_class_free(cls); obj->ops = NULL; if (mtype) free(obj, mtype); }