class_refcounted.rst 8.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/RefCounted.xml.
  6. .. _class_RefCounted:
  7. RefCounted
  8. ==========
  9. **Inherits:** :ref:`Object<class_Object>`
  10. **Inherited By:** :ref:`AESContext<class_AESContext>`, :ref:`AStar2D<class_AStar2D>`, :ref:`AStar3D<class_AStar3D>`, :ref:`AnimationTrackEditPlugin<class_AnimationTrackEditPlugin>`, :ref:`AudioEffectInstance<class_AudioEffectInstance>`, :ref:`AudioStreamPlayback<class_AudioStreamPlayback>`, :ref:`CameraFeed<class_CameraFeed>`, :ref:`CharFXTransform<class_CharFXTransform>`, :ref:`ConfigFile<class_ConfigFile>`, :ref:`Crypto<class_Crypto>`, :ref:`DTLSServer<class_DTLSServer>`, :ref:`Directory<class_Directory>`, :ref:`ENetConnection<class_ENetConnection>`, :ref:`EditorExportPlugin<class_EditorExportPlugin>`, :ref:`EditorFeatureProfile<class_EditorFeatureProfile>`, :ref:`EditorFileSystemImportFormatSupportQuery<class_EditorFileSystemImportFormatSupportQuery>`, :ref:`EditorInspectorPlugin<class_EditorInspectorPlugin>`, :ref:`EditorResourceConversionPlugin<class_EditorResourceConversionPlugin>`, :ref:`EditorResourcePreviewGenerator<class_EditorResourcePreviewGenerator>`, :ref:`EditorSceneFormatImporter<class_EditorSceneFormatImporter>`, :ref:`EditorScenePostImport<class_EditorScenePostImport>`, :ref:`EditorScenePostImportPlugin<class_EditorScenePostImportPlugin>`, :ref:`EditorScript<class_EditorScript>`, :ref:`EditorTranslationParserPlugin<class_EditorTranslationParserPlugin>`, :ref:`EncodedObjectAsID<class_EncodedObjectAsID>`, :ref:`EngineProfiler<class_EngineProfiler>`, :ref:`Expression<class_Expression>`, :ref:`File<class_File>`, :ref:`HMACContext<class_HMACContext>`, :ref:`HTTPClient<class_HTTPClient>`, :ref:`HashingContext<class_HashingContext>`, :ref:`JSON<class_JSON>`, :ref:`JavaClass<class_JavaClass>`, :ref:`JavaScriptObject<class_JavaScriptObject>`, :ref:`KinematicCollision2D<class_KinematicCollision2D>`, :ref:`KinematicCollision3D<class_KinematicCollision3D>`, :ref:`Lightmapper<class_Lightmapper>`, :ref:`MeshDataTool<class_MeshDataTool>`, :ref:`MultiplayerAPI<class_MultiplayerAPI>`, :ref:`Mutex<class_Mutex>`, :ref:`Node3DGizmo<class_Node3DGizmo>`, :ref:`OGGPacketSequencePlayback<class_OGGPacketSequencePlayback>`, :ref:`PCKPacker<class_PCKPacker>`, :ref:`PackedDataContainerRef<class_PackedDataContainerRef>`, :ref:`PacketPeer<class_PacketPeer>`, :ref:`PhysicsPointQueryParameters2D<class_PhysicsPointQueryParameters2D>`, :ref:`PhysicsPointQueryParameters3D<class_PhysicsPointQueryParameters3D>`, :ref:`PhysicsRayQueryParameters2D<class_PhysicsRayQueryParameters2D>`, :ref:`PhysicsRayQueryParameters3D<class_PhysicsRayQueryParameters3D>`, :ref:`PhysicsShapeQueryParameters2D<class_PhysicsShapeQueryParameters2D>`, :ref:`PhysicsShapeQueryParameters3D<class_PhysicsShapeQueryParameters3D>`, :ref:`PhysicsTestMotionParameters2D<class_PhysicsTestMotionParameters2D>`, :ref:`PhysicsTestMotionParameters3D<class_PhysicsTestMotionParameters3D>`, :ref:`PhysicsTestMotionResult2D<class_PhysicsTestMotionResult2D>`, :ref:`PhysicsTestMotionResult3D<class_PhysicsTestMotionResult3D>`, :ref:`RDAttachmentFormat<class_RDAttachmentFormat>`, :ref:`RDFramebufferPass<class_RDFramebufferPass>`, :ref:`RDPipelineColorBlendState<class_RDPipelineColorBlendState>`, :ref:`RDPipelineColorBlendStateAttachment<class_RDPipelineColorBlendStateAttachment>`, :ref:`RDPipelineDepthStencilState<class_RDPipelineDepthStencilState>`, :ref:`RDPipelineMultisampleState<class_RDPipelineMultisampleState>`, :ref:`RDPipelineRasterizationState<class_RDPipelineRasterizationState>`, :ref:`RDPipelineSpecializationConstant<class_RDPipelineSpecializationConstant>`, :ref:`RDSamplerState<class_RDSamplerState>`, :ref:`RDShaderSource<class_RDShaderSource>`, :ref:`RDTextureFormat<class_RDTextureFormat>`, :ref:`RDTextureView<class_RDTextureView>`, :ref:`RDUniform<class_RDUniform>`, :ref:`RDVertexAttribute<class_RDVertexAttribute>`, :ref:`RandomNumberGenerator<class_RandomNumberGenerator>`, :ref:`RegEx<class_RegEx>`, :ref:`RegExMatch<class_RegExMatch>`, :ref:`Resource<class_Resource>`, :ref:`ResourceFormatLoader<class_ResourceFormatLoader>`, :ref:`ResourceFormatSaver<class_ResourceFormatSaver>`, :ref:`ResourceImporter<class_ResourceImporter>`, :ref:`SceneState<class_SceneState>`, :ref:`SceneTreeTimer<class_SceneTreeTimer>`, :ref:`Semaphore<class_Semaphore>`, :ref:`SkinReference<class_SkinReference>`, :ref:`StreamPeer<class_StreamPeer>`, :ref:`SurfaceTool<class_SurfaceTool>`, :ref:`TCPServer<class_TCPServer>`, :ref:`TextLine<class_TextLine>`, :ref:`TextParagraph<class_TextParagraph>`, :ref:`TextServer<class_TextServer>`, :ref:`Thread<class_Thread>`, :ref:`TriangleMesh<class_TriangleMesh>`, :ref:`Tween<class_Tween>`, :ref:`Tweener<class_Tweener>`, :ref:`UDPServer<class_UDPServer>`, :ref:`UPNP<class_UPNP>`, :ref:`UPNPDevice<class_UPNPDevice>`, :ref:`VelocityTracker3D<class_VelocityTracker3D>`, :ref:`VisualScriptFunctionState<class_VisualScriptFunctionState>`, :ref:`WeakRef<class_WeakRef>`, :ref:`WebRTCPeerConnection<class_WebRTCPeerConnection>`, :ref:`XMLParser<class_XMLParser>`, :ref:`XRInterface<class_XRInterface>`, :ref:`XRPose<class_XRPose>`, :ref:`XRPositionalTracker<class_XRPositionalTracker>`
  11. Base class for reference-counted objects.
  12. Description
  13. -----------
  14. Base class for any object that keeps a reference count. :ref:`Resource<class_Resource>` and many other helper objects inherit this class.
  15. Unlike other :ref:`Object<class_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 :ref:`Object.free<class_Object_method_free>`.
  16. 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.
  17. \ **Note:** 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.
  18. Tutorials
  19. ---------
  20. - :doc:`When and how to avoid using nodes for everything <../tutorials/best_practices/node_alternatives>`
  21. Methods
  22. -------
  23. +-------------------------+---------------------------------------------------------------------+
  24. | :ref:`bool<class_bool>` | :ref:`init_ref<class_RefCounted_method_init_ref>` **(** **)** |
  25. +-------------------------+---------------------------------------------------------------------+
  26. | :ref:`bool<class_bool>` | :ref:`reference<class_RefCounted_method_reference>` **(** **)** |
  27. +-------------------------+---------------------------------------------------------------------+
  28. | :ref:`bool<class_bool>` | :ref:`unreference<class_RefCounted_method_unreference>` **(** **)** |
  29. +-------------------------+---------------------------------------------------------------------+
  30. Method Descriptions
  31. -------------------
  32. .. _class_RefCounted_method_init_ref:
  33. - :ref:`bool<class_bool>` **init_ref** **(** **)**
  34. Initializes the internal reference counter. Use this only if you really know what you are doing.
  35. Returns whether the initialization was successful.
  36. ----
  37. .. _class_RefCounted_method_reference:
  38. - :ref:`bool<class_bool>` **reference** **(** **)**
  39. Increments the internal reference counter. Use this only if you really know what you are doing.
  40. Returns ``true`` if the increment was successful, ``false`` otherwise.
  41. ----
  42. .. _class_RefCounted_method_unreference:
  43. - :ref:`bool<class_bool>` **unreference** **(** **)**
  44. Decrements the internal reference counter. Use this only if you really know what you are doing.
  45. Returns ``true`` if the decrement was successful, ``false`` otherwise.
  46. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  47. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  48. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  49. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  50. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  51. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`