You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$x = newWeakRef($obj);
$x->onLoss(function() use($map){
echo"the object was garbage collected";
$map->remove($weakref);
});
// or even...$x->onBeforeLoss(function($object){
echo"the object is about to be garbage collected";
$map->save($object->serialize());
// $weakref->acquire(); -> triggers "you aren't allowed to acquire a strong reference here"
});
The text was updated successfully, but these errors were encountered:
I think this would be good to have indeed. I need to reimplement most of weakref for php7 as the internals have changed (I'm not even sure weakref is possible anymore). Therefore it might be available only for php7 at first.
@colder look how I implement notify callbacks functionality in my code in php_weak_referent_object_dtor_obj() at php_weak_reference.c:L126, the only drawback is if exception thrown in original dtor and in any of notifiers, all further notifiers will not be called.
I follow python's weakref.ref's notify appoach where notify callback get called with a weakref.ref object as a first arg after referent object destructed.
imagine the following:
The text was updated successfully, but these errors were encountered: