DABC (Data Acquisition Backbone Core)  2.9.9
Destroyment of object

Object live may be complex but way to destroy it much more complex.

Problems are:

  • multiple references on object from different threads
  • need to cleanup of object from the thread where it is used
  • object does not want to be destroyed All this complexity handled by the dabc::Object::Destroy(obj) call.

First, object is checked that if it is assigned with a thread (flHasThread). It means that object can be actively used in the thread and any cleanup should happen from this thread. In this case DestroyByOwnThread() method will be called. Method can return true only when objects allowed to be destroyed immediately

If object does not have thread, ObjectCleanup() will be called immediately, otherwise it will be called in thread context. Main motivation for ObjectCleanup() is to release references on all other objects which may be used inside. One also can free buffers, close files and do any other relevant job here.

At the end will be checked existing references on the object. If any exists, object will be moved to manager cleanup queue. Manager will try to check if reference can be cleared and finally delete object.

TODO: dabc::Object::Destroy() should not be used very often, rather reference on the object must be used Therefore one should try to avoid dabc::Object::Destroy() as much as possible