You've already forked lazarus-ccr
OS X compatibility patch, Thanks to Phil for testing.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@537 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@@ -16,7 +16,7 @@ unit object_serializer;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils, TypInfo, Contnrs,
|
Classes, SysUtils, TypInfo, Contnrs, SyncObjs,
|
||||||
base_service_intf, wst_types;
|
base_service_intf, wst_types;
|
||||||
|
|
||||||
type
|
type
|
||||||
@@ -95,9 +95,10 @@ type
|
|||||||
|
|
||||||
TBaseComplexTypeRegistryItem = class(TTypeRegistryItem)
|
TBaseComplexTypeRegistryItem = class(TTypeRegistryItem)
|
||||||
private
|
private
|
||||||
FGetterLock : PtrInt;
|
FGetterLock : TCriticalSection;
|
||||||
FSerializer : TObjectSerializer;
|
FSerializer : TObjectSerializer;
|
||||||
FGetFunction : TGetSerializerFunction;
|
FGetFunction : TGetSerializerFunction;
|
||||||
|
FFuncIsNotReady : Boolean;
|
||||||
private
|
private
|
||||||
function FirstGetter() : TObjectSerializer;
|
function FirstGetter() : TObjectSerializer;
|
||||||
function StaticGetter() : TObjectSerializer;
|
function StaticGetter() : TObjectSerializer;
|
||||||
@@ -132,13 +133,6 @@ resourcestring
|
|||||||
SERR_SerializerInitializationException = 'Unable to initialize the serializer of that type : "%s".';
|
SERR_SerializerInitializationException = 'Unable to initialize the serializer of that type : "%s".';
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
{$IFDEF WST_DELPHI}
|
|
||||||
{$IFDEF MSWINDOWS}
|
|
||||||
uses
|
|
||||||
Windows;
|
|
||||||
{$ENDIF MSWINDOWS}
|
|
||||||
{$ENDIF WST_DELPHI}
|
|
||||||
|
|
||||||
|
|
||||||
procedure ErrorProc(
|
procedure ErrorProc(
|
||||||
AObject : TObject;
|
AObject : TObject;
|
||||||
@@ -1175,26 +1169,17 @@ end;
|
|||||||
{ TBaseComplexTypeRegistryItem }
|
{ TBaseComplexTypeRegistryItem }
|
||||||
|
|
||||||
function TBaseComplexTypeRegistryItem.FirstGetter() : TObjectSerializer;
|
function TBaseComplexTypeRegistryItem.FirstGetter() : TObjectSerializer;
|
||||||
var
|
|
||||||
oldValue : PtrInt;
|
|
||||||
begin
|
begin
|
||||||
if ( InterlockedCompareExchange(Pointer(FGetterLock),Pointer(1),Pointer(0)) = Pointer(0) ) then begin
|
FGetterLock.Acquire();
|
||||||
try
|
try
|
||||||
|
if ( FSerializer = nil ) then begin
|
||||||
FSerializer := TObjectSerializer.Create(TBaseComplexRemotableClass(GetTypeData(DataType)^.ClassType),Owner);
|
FSerializer := TObjectSerializer.Create(TBaseComplexRemotableClass(GetTypeData(DataType)^.ClassType),Owner);
|
||||||
except
|
FFuncIsNotReady := True;
|
||||||
InterLockedDecrement(FGetterLock);
|
FGetFunction := {$IFDEF FPC}@{$ENDIF}StaticGetter;
|
||||||
raise;
|
FFuncIsNotReady := False;
|
||||||
end;
|
end;
|
||||||
FGetFunction := {$IFDEF FPC}@{$ENDIF}StaticGetter;
|
finally
|
||||||
InterLockedIncrement(FGetterLock);
|
FGetterLock.Release();
|
||||||
end else begin
|
|
||||||
repeat
|
|
||||||
//this is a way t get the value of "FGetterLock" without altering it.
|
|
||||||
oldValue := PtrInt(InterlockedCompareExchange(Pointer(FGetterLock),Pointer(1),Pointer(12)));
|
|
||||||
//this is a busy wait!
|
|
||||||
until ( oldValue <> 1 );
|
|
||||||
if ( oldValue <> 2 ) then
|
|
||||||
raise ESerializerException.CreateFmt(SERR_SerializerInitializationException,[DataType^.Name]);
|
|
||||||
end;
|
end;
|
||||||
Result := FSerializer;
|
Result := FSerializer;
|
||||||
end;
|
end;
|
||||||
@@ -1213,16 +1198,21 @@ constructor TBaseComplexTypeRegistryItem.Create(
|
|||||||
begin
|
begin
|
||||||
inherited Create(AOwner, ANameSpace, ADataType, ADeclaredName);
|
inherited Create(AOwner, ANameSpace, ADataType, ADeclaredName);
|
||||||
FGetFunction := {$IFDEF FPC}@{$ENDIF}FirstGetter;
|
FGetFunction := {$IFDEF FPC}@{$ENDIF}FirstGetter;
|
||||||
|
FGetterLock := TCriticalSection.Create();
|
||||||
end;
|
end;
|
||||||
|
|
||||||
destructor TBaseComplexTypeRegistryItem.Destroy();
|
destructor TBaseComplexTypeRegistryItem.Destroy();
|
||||||
begin
|
begin
|
||||||
|
FGetterLock.Free();
|
||||||
FSerializer.Free();
|
FSerializer.Free();
|
||||||
inherited Destroy();
|
inherited Destroy();
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TBaseComplexTypeRegistryItem.GetSerializer() : TObjectSerializer;
|
function TBaseComplexTypeRegistryItem.GetSerializer() : TObjectSerializer;
|
||||||
begin
|
begin
|
||||||
|
while FFuncIsNotReady do begin
|
||||||
|
//busy wait
|
||||||
|
end;
|
||||||
Result := FGetFunction();
|
Result := FGetFunction();
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
37
wst/trunk/wst_delphi_rtl.pas
Normal file
37
wst/trunk/wst_delphi_rtl.pas
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
{
|
||||||
|
This file is part of the Web Service Toolkit
|
||||||
|
Copyright (c) 2008 by Inoussa OUEDRAOGO
|
||||||
|
|
||||||
|
This file is provide under modified LGPL licence
|
||||||
|
( the files COPYING.modifiedLGPL and COPYING.LGPL).
|
||||||
|
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
}
|
||||||
|
{$INCLUDE wst_global.inc}
|
||||||
|
unit wst_delphi_rtl;
|
||||||
|
|
||||||
|
interface
|
||||||
|
uses
|
||||||
|
wst_types;
|
||||||
|
|
||||||
|
{$IFDEF WST_DELPHI}
|
||||||
|
function InterlockedExchange(var Target: Pointer; Value: Pointer): Integer; stdcall;
|
||||||
|
{$ENDIF WST_DELPHI}
|
||||||
|
|
||||||
|
implementation
|
||||||
|
{$IFDEF WST_DELPHI}
|
||||||
|
uses
|
||||||
|
Windows;
|
||||||
|
{$ENDIF WST_DELPHI}
|
||||||
|
|
||||||
|
{$IFDEF WST_DELPHI}
|
||||||
|
function InterlockedExchange(var Target: Pointer; Value: Pointer): Integer;
|
||||||
|
begin
|
||||||
|
Windows.InterlockedExchange(PtrInt(Target),PtrInt(Value));
|
||||||
|
end;
|
||||||
|
{$ENDIF WST_DELPHI}
|
||||||
|
|
||||||
|
end.
|
Reference in New Issue
Block a user