Skip to content

Observe gc events for the weakref? Would it work? #16

Open
@Wes0617

Description

@Wes0617

imagine the following:

$x = new WeakRef($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"
});

Metadata

Metadata

Assignees

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions