+ made the ref. couting MT safe

This commit is contained in:
florian 2001-05-27 14:28:44 +00:00
parent 4870698a11
commit 23b3c24a01
3 changed files with 43 additions and 15 deletions

View File

@ -121,8 +121,9 @@ Begin
{ check for constant strings ...}
l:=@PANSIREC(S-FirstOff)^.Ref;
If l^<0 then exit;
Dec(l^);
If l^=0 then
{ declocked does a MT safe dec and returns true, if the counter is 0 }
If declocked(l^) then
{ Ref count dropped to zero }
DisposeAnsiString (S); { Remove...}
{ this pointer is not valid anymore, so set it to zero }
@ -136,7 +137,7 @@ Begin
exit;
{ Let's be paranoid : Constant string ??}
If PAnsiRec(S-FirstOff)^.Ref<0 then exit;
Inc(PAnsiRec(S-FirstOff)^.Ref);
inclocked(PAnsiRec(S-FirstOff)^.Ref);
end;
@ -725,7 +726,10 @@ end;
{
$Log$
Revision 1.10 2001-04-13 18:06:07 peter
Revision 1.11 2001-05-27 14:28:44 florian
+ made the ref. couting MT safe
Revision 1.10 2001/04/13 18:06:07 peter
* upcase, lowercase for ansistring
Revision 1.9 2000/12/10 15:00:14 florian

View File

@ -81,17 +81,29 @@ procedure dynarray_decr_ref(var p : pointer;ti : pdynarraytypeinfo);[Public,Alia
if realp^.refcount=0 then
HandleErrorFrame(204,get_frame);
{ this isn't MT safe! }
{ decr. ref. count }
declocked(realp^.refcount);
{ should we remove the array? }
if realp^.refcount=0 then
if declocked(realp^.refcount) then
dynarray_clear(realp,ti);
p:=nil;
end;
procedure dynarray_incr_ref(var p : pointer);[Public,Alias:'FPC_DYNARRAY_INCR_REF'];
var
realp : pdynarray;
begin
if p=nil then
exit;
realp:=pdynarray(p-sizeof(tdynarray));
if realp^.refcount=0 then
HandleErrorFrame(204,get_frame);
inclocked(realp^.refcount);
end;
procedure dynarray_setlength(var p : pointer;pti : pdynarraytypeinfo;
dimcount : dword;dims : pdynarrayindex);[Public,Alias:'FPC_DYNARR_SETLENGTH'];
@ -146,6 +158,9 @@ procedure dynarray_setlength(var p : pointer;pti : pdynarraytypeinfo;
{ it could be that the in MT enviroments }
{ in the mean time the refcount was }
{ decremented }
{ it is, because it doesn't really matter }
{ if the array is now removed }
dynarray_decr_ref(p,ti);
end
else if dims[0]<>realp^.high+1 then
@ -202,7 +217,10 @@ function dynarray_copy(var p : pointer;ti : pdynarraytypeinfo;
{
$Log$
Revision 1.6 2001-04-13 23:49:48 peter
Revision 1.7 2001-05-27 14:28:44 florian
+ made the ref. couting MT safe
Revision 1.6 2001/04/13 23:49:48 peter
* fixes for the stricter compiler
Revision 1.5 2000/12/01 23:30:00 florian

View File

@ -636,10 +636,13 @@
function TInterfacedObject._Release : longint;stdcall;
begin
declocked(frefcount);
_release:=frefcount;
if frefcount=0 then
destroy;
if declocked(frefcount) then
begin
destroy;
_Release:=0;
end
else
_Release:=frefcount;
end;
procedure TInterfacedObject.AfterConstruction;
@ -678,14 +681,17 @@
{
$Log$
Revision 1.14 2001-04-13 22:30:04 peter
Revision 1.15 2001-05-27 14:28:44 florian
+ made the ref. couting MT safe
Revision 1.14 2001/04/13 22:30:04 peter
* remove warnings
Revision 1.13 2000/12/20 21:38:23 florian
* is-operator fixed
Revision 1.12 2000/11/12 23:23:34 florian
* interfaces basically running
* interfaces are basically running
Revision 1.11 2000/11/09 17:50:12 florian
* Finalize to int_finalize renamed