libmexclass should keep a list of "unmanaged" proxy IDs that can be reused. Currently, once a proxy ID is handed out, it cannot be reused even if the object associated with the ID has been deleted.
Change
Added a new member variable called recycled_ids to ProxyManager. recycled_ids is a std::deque<ID>
ProxyManager::unmanageProxy(ID) pushes the unmanaged proxy ID to the back of recycled_ids.
ProxyManager::manageProxy(proxy) checks if recycled_ids is not empty. If so, it pops the first ID from recycled_ids and uses it as the ID for the newly managed proxy. Otherwise, it uses current_proxy_id as the new ID and increments current_proxy_id by one.
Testing
Manually verified that libmexclass reuses proxy IDs if they are available. Otherwise, it creates new proxy IDs.
Rationale
libmexclass
should keep a list of "unmanaged" proxy IDs that can be reused. Currently, once a proxy ID is handed out, it cannot be reused even if the object associated with the ID has been deleted.Change
recycled_ids
toProxyManager
.recycled_ids
is astd::deque<ID>
ProxyManager::unmanageProxy(ID)
pushes the unmanaged proxy ID to the back ofrecycled_ids
.ProxyManager::manageProxy(proxy)
checks ifrecycled_ids
is not empty. If so, it pops the first ID fromrecycled_ids
and uses it as the ID for the newly managed proxy. Otherwise, it usescurrent_proxy_id
as the new ID and incrementscurrent_proxy_id
by one.Testing
Manually verified that
libmexclass
reuses proxy IDs if they are available. Otherwise, it creates new proxy IDs.