Contains classes and routines used to implement free notifications and reference counting.

lazclasses.pas is part of the lazutils package.

Generic implementation of the class used to implement objects which perform free notifications. Alternate destructor for the generic class type.

FPC issues an error and can not compile an overridden Destructor.

Adds the specified notification to the notification list in the generic class instance. The notification event handler added to the notification list. Removes the specified notification from the notification list in the generic class instance. The notification event handler removed from the notification list. Base class used to implement objects which perform free notifications. List of notification methods called when the object is freed. Destructor for the class instance. Adds the specified method to the notification list in the class instance. The notification event handler added to the internal list. Removes the specified method from the internal list. The notification event handler removed from the internal list. Implements a thread-safe reference-counted class which performs free notifications.

Used in the implementation of logging classes and the debugger interface in Lazarus. Also used in the implementation of classes for TSynEdit.

Performs actions needed to free the reference counted object instance.

Calls the inherited Free method.

Has an empty implementation in TRefCountedObject. Has an empty implementation in TRefCountedObject. Number of times the object instance has been referenced in the application.

RefCount is a read-only Integer property which contains the number of times the object instance has been referenced. Its value is maintained when methods like AddReference and ReleaseReference are called.

Constructor for the class instance.

Create is the constructor for the class instance. It sets the default values for members used in the class instance.When WITH_REFCOUNT_DEBUG has been defined in the LCL, a critical section used during debugging is initialized. Create calls the inherited constructor prior to exiting from the method.

Destructor for the class instance.

Destroy is the overridden destructor for the class instance. It ensures that resource allocated in the constructor are freed before freeing the class instance. Destroy calls the inherited destructor prior to exit.

Destroy raises an EAssertionFailed exception if RefCount has a non-zero value when the method was called.
Increments the value in RefCount and calls DoReferenceAdded.

AddReference and ReleaseReference can be used in threads. However a thread can only call the methods, if either:

  • The thread already holds a reference (and no other thread will release that reference).
  • The thread created the reference, and no other thread has access to the object (yet).
  • The thread is in a critical section, preventing other threads from decreasing the reference count.
Debugging symbol. Debugging symbol. Decrements the value in RefCount and calls DoReferenceReleased.

AddReference and ReleaseReference can be used in threads. However a thread can only call the methods, if either:

  • The thread already holds a reference (and no other thread will release that reference).
  • The thread created the reference, and no other thread has access to the object (yet).
  • The thread is in a critical section, preventing other threads from decreasing the reference count.
Debugging symbol. Debugging symbol. implemented when WITH_REFCOUNT_DEBUG is defined in the LCL. Debugging symbol. Debugging symbol. Debugging symbol. Debugging symbol. Implements a list used to store TRefCountedObject instances.

Provides a Notify method which increases or decreases the reference count for an object when it is added to or removed from the list.ist.

Performs a notification when an object is added to or removed from the list.

For TRefCntObjList, the notification causes the reference count for the object in Ptr to be increased or decreased as needed for the value in Action.

Pointer to the object instance for the notification. Identifies the action that caused the list notification. Releases the specified reference counted object and sets it to Nil.

No actions are performed in the method when ARefCountedObject has not been assigned, or has already been released. ReleaseRefAndNil calls the ReleaseReference method for the object instance, and sets the pointer in ARefCountedObject to Nil.

Raises an EAssertionFailed exception if the object instance in ARefCountedObject is derived from a class other than TRefCountedObject.
TRefCountedObject object instance examined and updated in the routine. Debugging symbol. Debugging symbol. Copies and releases the specified reference counted object, and sets the copy to Nil.

No actions are performed in the method when ARefCountedObject has not been assigned, or has already been released. ReleaseRefAndNil calls the ReleaseReference method for the object instance, and sets the pointer in ARefCountedObject to Nil.

Raises an EAssertionFailed exception if the object instance in ARefCountedObject is derived from a class other than TRefCountedObject.
TRefCountedObject object instance examined and updated in the routine. Debugging symbol. Debugging symbol.