RefCounted.xml 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="RefCounted" inherits="Object" version="4.0">
  3. <brief_description>
  4. Base class for reference-counted objects.
  5. </brief_description>
  6. <description>
  7. Base class for any object that keeps a reference count. [Resource] and many other helper objects inherit this class.
  8. Unlike other [Object] types, [RefCounted]s keep an internal reference counter so that they are automatically released when no longer in use, and only then. [RefCounted]s therefore do not need to be freed manually with [method Object.free].
  9. In the vast majority of use cases, instantiating and using [RefCounted]-derived types is all you need to do. The methods provided in this class are only for advanced users, and can cause issues if misused.
  10. [b]Note:[/b] In C#, reference-counted objects will not be freed instantly after they are no longer in use. Instead, garbage collection will run periodically and will free reference-counted objects that are no longer in use. This means that unused ones will linger on for a while before being removed.
  11. </description>
  12. <tutorials>
  13. <link title="When and how to avoid using nodes for everything">https://docs.godotengine.org/en/latest/tutorials/best_practices/node_alternatives.html</link>
  14. </tutorials>
  15. <methods>
  16. <method name="init_ref">
  17. <return type="bool" />
  18. <description>
  19. Initializes the internal reference counter. Use this only if you really know what you are doing.
  20. Returns whether the initialization was successful.
  21. </description>
  22. </method>
  23. <method name="reference">
  24. <return type="bool" />
  25. <description>
  26. Increments the internal reference counter. Use this only if you really know what you are doing.
  27. Returns [code]true[/code] if the increment was successful, [code]false[/code] otherwise.
  28. </description>
  29. </method>
  30. <method name="unreference">
  31. <return type="bool" />
  32. <description>
  33. Decrements the internal reference counter. Use this only if you really know what you are doing.
  34. Returns [code]true[/code] if the decrement was successful, [code]false[/code] otherwise.
  35. </description>
  36. </method>
  37. </methods>
  38. </class>