Back

IntrusiveObject

The `IntrusiveObject` class in the SOFA framework is designed to implement an internal reference counting mechanism for managing its own lifetime. This mechanism works in conjunction with intrusive smart pointers, such as `boost::intrusive_ptr`. The primary role of `IntrusiveObject` is to ensure proper memory management by tracking references to itself and deleting instances when no more references exist. It is intended to be used within the SOFA ecosystem where precise control over object lifetimes is necessary. Interactions with other components in SOFA are facilitated through intrusive smart pointers, which use `IntrusiveObject`'s internal reference counting methods (`addRef()` and `release()`) for managing object lifetime. This ensures that objects are only deleted when all references have been released, preventing premature deallocation or memory leaks. Practical usage involves inheriting from `IntrusiveObject` and using intrusive smart pointers to manage the lifecycle of these derived classes. The internal reference counting mechanism is thread-safe due to the use of atomic operations (`std::atomic<int>`), which allows safe use in multi-threaded scenarios.

abstract
`IntrusiveObject` implements an internal reference counting mechanism to manage object lifetimes using intrusive smart pointers like `boost::intrusive_ptr`, ensuring thread-safe memory management within the SOFA ecosystem.
sheet
# IntrusiveObject ## Overview The `IntrusiveObject` class in the SOFA framework is designed for managing object lifetimes through internal reference counting. It works with intrusive smart pointers, such as `boost::intrusive_ptr`, to ensure that objects are only deleted when no more references exist, preventing premature deallocation or memory leaks. ## Practical Notes The internal reference counting mechanism in `IntrusiveObject` is thread-safe due to the use of atomic operations (`std::atomic<int>`). This ensures safe usage in multi-threaded scenarios. Proper configuration and usage involve inheriting from `IntrusiveObject` and using intrusive smart pointers for managing object lifecycles.
description
The `IntrusiveObject` class in the SOFA framework is designed to implement an internal reference counting mechanism for managing its own lifetime. This mechanism works in conjunction with intrusive smart pointers, such as `boost::intrusive_ptr`. The primary role of `IntrusiveObject` is to ensure proper memory management by tracking references to itself and deleting instances when no more references exist. It is intended to be used within the SOFA ecosystem where precise control over object lifetimes is necessary. Interactions with other components in SOFA are facilitated through intrusive smart pointers, which use `IntrusiveObject`'s internal reference counting methods (`addRef()` and `release()`) for managing object lifetime. This ensures that objects are only deleted when all references have been released, preventing premature deallocation or memory leaks. Practical usage involves inheriting from `IntrusiveObject` and using intrusive smart pointers to manage the lifecycle of these derived classes. The internal reference counting mechanism is thread-safe due to the use of atomic operations (`std::atomic<int>`), which allows safe use in multi-threaded scenarios.
maths
The `IntrusiveObject` class in the SOFA framework is designed to manage the lifetime of objects using an internal reference counting mechanism. This class does not directly contribute to the governing equations or operators typically associated with finite element methods (FEM) such as mass matrices, stiffness matrices, internal forces, or residuals. Instead, its primary role is to ensure proper memory management within the SOFA simulation pipeline. ### Governing Equations and Operators - **Mass Matrix**: Not applicable to `IntrusiveObject`. - **Stiffness Matrix**: Not applicable to `IntrusiveObject`. - **Internal Force**: Not applicable to `IntrusiveObject`. - **Residual**: Not applicable to `IntrusiveObject`. ### Constitutive or Kinematic Laws There are no constitutive or kinematic laws involved in the `IntrusiveObject` class. It does not define any strain measures, stress tensors, hyperelastic potentials, damping models, constraint Jacobians, etc. ### Role in the FEM Pipeline The role of `IntrusiveObject` is to provide a mechanism for managing object lifetimes through reference counting. This ensures that objects are only deleted when no more references exist, preventing premature deallocation or memory leaks. It operates at a lower level than the typical components involved in assembly, time integration, nonlinear solve, linear solve, constraint handling, and mappings. ### Numerical Methods or Discretization Choices The `IntrusiveObject` class uses atomic operations (`std::atomic<int>`) to ensure thread-safe reference counting. This is crucial for multi-threaded scenarios where concurrent access to the reference count must be managed safely. ### Integration into Variational / Lagrangian Mechanics Framework While `IntrusiveObject` itself does not directly contribute to variational or Lagrangian mechanics, it supports other components within the SOFA framework that do. Proper memory management ensures that these components can operate reliably and efficiently without issues related to premature deallocation or dangling pointers. ### Summary The `IntrusiveObject` class provides an internal reference counting mechanism for managing object lifetimes in a thread-safe manner. It does not contribute directly to the FEM simulation pipeline but supports other components by ensuring proper memory management.
{
  "name": "IntrusiveObject",
  "main": {
    "name": "IntrusiveObject",
    "namespace": "sofa::core",
    "module": "Sofa.framework.Core",
    "include": "sofa/core/IntrusiveObject.h",
    "doc": "The `IntrusiveObject` class implements an internal reference counting mechanism\nto manage its lifetime. It is intended to work with intrusive smart pointers like\n`boost::intrusive_ptr`.",
    "inherits": [],
    "templates": [],
    "data_fields": [],
    "links": [],
    "methods": []
  },
  "desc": {
    "description": "The `IntrusiveObject` class in the SOFA framework is designed to implement an internal reference counting mechanism for managing its own lifetime. This mechanism works in conjunction with intrusive smart pointers, such as `boost::intrusive_ptr`. The primary role of `IntrusiveObject` is to ensure proper memory management by tracking references to itself and deleting instances when no more references exist. It is intended to be used within the SOFA ecosystem where precise control over object lifetimes is necessary.\n\nInteractions with other components in SOFA are facilitated through intrusive smart pointers, which use `IntrusiveObject`'s internal reference counting methods (`addRef()` and `release()`) for managing object lifetime. This ensures that objects are only deleted when all references have been released, preventing premature deallocation or memory leaks.\n\nPractical usage involves inheriting from `IntrusiveObject` and using intrusive smart pointers to manage the lifecycle of these derived classes. The internal reference counting mechanism is thread-safe due to the use of atomic operations (`std::atomic<int>`), which allows safe use in multi-threaded scenarios."
  },
  "maths": {
    "maths": "The `IntrusiveObject` class in the SOFA framework is designed to manage the lifetime of objects using an internal reference counting mechanism. This class does not directly contribute to the governing equations or operators typically associated with finite element methods (FEM) such as mass matrices, stiffness matrices, internal forces, or residuals. Instead, its primary role is to ensure proper memory management within the SOFA simulation pipeline.\n\n### Governing Equations and Operators\n- **Mass Matrix**: Not applicable to `IntrusiveObject`.\n- **Stiffness Matrix**: Not applicable to `IntrusiveObject`.\n- **Internal Force**: Not applicable to `IntrusiveObject`.\n- **Residual**: Not applicable to `IntrusiveObject`.\n\n### Constitutive or Kinematic Laws\nThere are no constitutive or kinematic laws involved in the `IntrusiveObject` class. It does not define any strain measures, stress tensors, hyperelastic potentials, damping models, constraint Jacobians, etc.\n\n### Role in the FEM Pipeline\nThe role of `IntrusiveObject` is to provide a mechanism for managing object lifetimes through reference counting. This ensures that objects are only deleted when no more references exist, preventing premature deallocation or memory leaks. It operates at a lower level than the typical components involved in assembly, time integration, nonlinear solve, linear solve, constraint handling, and mappings.\n\n### Numerical Methods or Discretization Choices\nThe `IntrusiveObject` class uses atomic operations (`std::atomic<int>`) to ensure thread-safe reference counting. This is crucial for multi-threaded scenarios where concurrent access to the reference count must be managed safely.\n\n### Integration into Variational / Lagrangian Mechanics Framework\nWhile `IntrusiveObject` itself does not directly contribute to variational or Lagrangian mechanics, it supports other components within the SOFA framework that do. Proper memory management ensures that these components can operate reliably and efficiently without issues related to premature deallocation or dangling pointers.\n\n### Summary\nThe `IntrusiveObject` class provides an internal reference counting mechanism for managing object lifetimes in a thread-safe manner. It does not contribute directly to the FEM simulation pipeline but supports other components by ensuring proper memory management."
  },
  "summary": {
    "abstract": "`IntrusiveObject` implements an internal reference counting mechanism to manage object lifetimes using intrusive smart pointers like `boost::intrusive_ptr`, ensuring thread-safe memory management within the SOFA ecosystem.",
    "sheet": "\n# IntrusiveObject\n\n## Overview\nThe `IntrusiveObject` class in the SOFA framework is designed for managing object lifetimes through internal reference counting. It works with intrusive smart pointers, such as `boost::intrusive_ptr`, to ensure that objects are only deleted when no more references exist, preventing premature deallocation or memory leaks.\n\n## Practical Notes\nThe internal reference counting mechanism in `IntrusiveObject` is thread-safe due to the use of atomic operations (`std::atomic<int>`). This ensures safe usage in multi-threaded scenarios. Proper configuration and usage involve inheriting from `IntrusiveObject` and using intrusive smart pointers for managing object lifecycles."
  }
}