RegisterAxit

 (Available in 01 TS COM - TS_COM_InterfaceSafe)

Purpose

Tell the GC to call the 'Axit' method

Syntax

SELF:RegisterAxit( )

Description

This method will make sure that the function 'RegisterAxit()' is called only one's. Also it will make sure that the 'UnRegisterAxit()' method is called to revoke 'Axit()' calling from the GC.

It is prefered to call the 'Axit()' method instead of the 'Destroy()' method when the application wants to do a explicit destroy of the object in that case the 'Axit()' method will make sure that the 'Destroy()' method of the object is called only one time. This can be a real time saver when the object has a long and/or complex destroy method.

Note: It is not adviced to do any 'real' work while in the 'Axit' method use the 'Destroy()' method for this purpose.

Note: Please try to refrain from allocating and/or de-allocating dynamic memory while in the 'Axit()' or 'Destroy()' method.

Note: The 'TS_Root0' class does not support a owner. Use the 'TS_Root1' class is a owner needs to be registered.

Note: The 'TS_Root0' class does not supports owned's, If you want to automaticly build an owner/owneds-tree then use the 'TS_Root2' class.

Example

oObject:=SomeObject{ }
IF oObject:IsValidObject
// Use the object
   oObject:Axit( )
   oObject:=NULL_OBJECT
ELSE
   oObject:Axit( )
   oObject:=NULL_OBJECT
   TSTrace Warning "Can not instantiate 'SomeObject'"
END

Source

METHOD RegisterAxit( ) AS TS_Root0 PASCAL CLASS TS_InterfaceSafe
LOCAL oCOMGlobalData AS _TS_COMGlobalData
   TSTrace Enter
   oCOMGlobalData:=_TS_ModuleGetCOMGlobalData( )
   #IFDEF TS_COMGLOBALDATA_CRITICALSECTION
      EnterCriticalSection( oCOMGlobalData:_COMGGeneralPurposeSection )
   #ENDIF
   IF !SELF:_InterfaceSafeCounted
      SELF:_InterfaceSafeCounted:=TRUE
      InterlockedIncrement( oCOMGlobalData:_ObjectsWithRegisterAxitCount  ; ...
     ... )
   END
   SUPER:RegisterAxit( )
   #IFDEF TS_COMGLOBALDATA_CRITICALSECTION
      LeaveCriticalSection( oCOMGlobalData:_COMGGeneralPurposeSection )
   #ENDIF
   TSTrace Leave
RETURN SELF