Subject: | UsedPool hash keys are stringified |
In the UsedPool structure of the ResourcePool object, objects are stored as hash keys.
Given two objects that stringify to the same thing this could be problematic.
Please use Tie::RefHash, and replace
$self->{UsedPool} = {};
with
tie %{ $self->{UsedPool} }, 'Tie::RefHash';
to get more correct behavior.
The current implementation also implies that a reference to the object is not kept. This implies that the object is unrecoverably destroyed, leaving it's associated ::Resource object still alive in the value of the hash, if whoever took the resource doesn't free it, but simply loses it.
This behavior is partially rectified, by at least making the leak preserve a consistent data structure.
You might instead use Tie::RefHash::Weak, and then the ::Resource object might get DESTROYed eventually (or immediately, if I ever get around to learning XS).