|
From: <na...@us...> - 2007-01-16 23:13:24
|
Revision: 752
http://svn.sourceforge.net/instantobjects/revision/?rev=752&view=rev
Author: nandod
Date: 2007-01-16 14:57:40 -0800 (Tue, 16 Jan 2007)
Log Message:
-----------
* moved InstantLogProc from InstantPersistence to InstantBrokers, where it is used.
+ added ability to disable circular reference checking by undefining IO_CIRCULAR_REFERENCE_CHECK
* documented the available IO_* defines in InstantDefines.inc.
* FreeCircularReferences slightly optimized.
Modified Paths:
--------------
trunk/Source/Core/InstantBrokers.pas
trunk/Source/Core/InstantPersistence.pas
trunk/Source/InstantDefines.inc
Modified: trunk/Source/Core/InstantBrokers.pas
===================================================================
--- trunk/Source/Core/InstantBrokers.pas 2007-01-16 17:09:37 UTC (rev 751)
+++ trunk/Source/Core/InstantBrokers.pas 2007-01-16 22:57:40 UTC (rev 752)
@@ -967,6 +967,9 @@
default True;
end;
+var
+ InstantLogProc: procedure (const AString: string) of object;
+
implementation
uses
Modified: trunk/Source/Core/InstantPersistence.pas
===================================================================
--- trunk/Source/Core/InstantPersistence.pas 2007-01-16 17:09:37 UTC (rev 751)
+++ trunk/Source/Core/InstantPersistence.pas 2007-01-16 22:57:40 UTC (rev 752)
@@ -796,7 +796,9 @@
procedure DoStore(ConflictAction: TInstantConflictAction);
procedure DoUnchange;
function FindDefaultContainer: TInstantContainer;
+{$IFDEF IO_CIRCULAR_REFERENCE_CHECK}
procedure FreeCircularReferences;
+{$ENDIF}
function GetClassId: string;
function GetDefaultContainer: TInstantContainer;
function GetHasDefaultContainer: Boolean;
@@ -1581,9 +1583,6 @@
InstantClassPrefix: string = 'T';
InstantAttributePrefix: string = '_';
-var
- InstantLogProc: procedure (const AString: string) of object;
-
implementation
uses
@@ -6059,6 +6058,7 @@
DestroyInternalFields;
end;
+{$IFDEF IO_CIRCULAR_REFERENCE_CHECK}
procedure TInstantObject.FreeCircularReferences;
var
CheckedObjects: TObjectList;
@@ -6114,27 +6114,35 @@
I: Integer;
begin
if RefByCount = RefCount - 1 then
- for I := Pred(RefByCount) downto 0 do
- begin
- CheckedObjects := TObjectList.Create(False);
- try
+ begin
+ CheckedObjects := TObjectList.Create(False);
+ try
+ for I := Pred(RefByCount) downto 0 do
+ begin
if (FRefBy[I] is TInstantComplex) and
IsInsideCircularReference(TInstantComplex(FRefBy[I])) then
+ begin
case TInstantComplex(FRefBy[I]).AttributeType of
atReference:
TInstantReference(FRefBy[I]).ObjectReference.DestroyInstance;
atReferences:
TInstantReferences(FRefBy[I]).DestroyObject(Self);
end;
- finally
- CheckedObjects.Free;
+ end;
+ CheckedObjects.Clear;
end;
+ finally
+ CheckedObjects.Free;
end;
+ end;
end;
+{$ENDIF}
procedure TInstantObject.FreeInstance;
begin
+{$IFDEF IO_CIRCULAR_REFERENCE_CHECK}
FreeCircularReferences;
+{$ENDIF}
DoRelease;
if FRefCount = 0 then
try
@@ -6779,7 +6787,9 @@
function TInstantObject._Release: Integer;
begin
+{$IFDEF IO_CIRCULAR_REFERENCE_CHECK}
FreeCircularReferences;
+{$ENDIF}
Result := DoRelease;
if FRefCount = 0 then
try
Modified: trunk/Source/InstantDefines.inc
===================================================================
--- trunk/Source/InstantDefines.inc 2007-01-16 17:09:37 UTC (rev 751)
+++ trunk/Source/InstantDefines.inc 2007-01-16 22:57:40 UTC (rev 752)
@@ -114,3 +114,21 @@
{$WARN UNSAFE_CAST OFF}
{$ENDIF}
+{
+ Define this symbol to enable logging of all SQL statements to the debug
+ console (via OutputDebugString - only on Windows) and to the procedure
+ pointed by the InstantBrokers.InstantLogProc global variable.
+}
+{.$DEFINE IO_STATEMENT_LOGGING}
+
+{
+ Whenever a TInstantObject is destroyed, a check is performed to see if there
+ are any objects that circularly refer to it, which should be destroyed as
+ well. If you are sure that your object model doesn't allow circular
+ references (as is the case with many object models, especially simple ones),
+ you can undefine this symbol to gain a little speed in programs that create
+ and destroy large quantities of objects.
+}
+{$DEFINE IO_CIRCULAR_REFERENCE_CHECK}
+
+
|