[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[IMP-dev] Inactive particles redux



Inactive particles are still a mess. For example, most of the optimizers will bomb if there are any inactive particles in the model (which, since we can't delete particles, there will be). The model iterators should skip inactive particles (that is easy enough), but then anything written in python which calls Model.get_particles() will still run in to them.

My best idea so far:  reference count particles.
-When the reference count goes to 1, then they are removed from the Model (since that means nothing other than the model points to them).
- Since they have no virtual functions, reference counting can be done.
- This way everything is safe and the user can't blow things up by inactivating particles. - Since nothing other than the optimizers should ever really be looking through all the particles in the model, leaving the particles there until the user cleans up all references should be ok. - If you want to delete a particle, you can make sure you do so by making sure that trying to fetch it from the Model fails. We do, perhaps, need to make sure that indexes aren't recycled too quickly.