ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/public/ibx/branches/udr/client/2.5/FB25Events.pas
(Generate patch)

Comparing:
ibx/trunk/fbintf/client/2.5/FB25Events.pas (file contents), Revision 45 by tony, Tue Dec 6 10:33:46 2016 UTC vs.
ibx/branches/udr/client/2.5/FB25Events.pas (file contents), Revision 370 by tony, Wed Jan 5 14:59:15 2022 UTC

# Line 60 | Line 60
60   {                                                                        }
61   {************************************************************************}
62   unit FB25Events;
63 + {$IFDEF MSWINDOWS}
64 + {$DEFINE WINDOWS}
65 + {$ENDIF}
66  
67   {$IFDEF FPC}
68 < {$mode objfpc}{$H+}
68 > {$mode delphi}
69   {$interfaces COM}
70   {$ENDIF}
71  
# Line 90 | Line 93 | type
93    public
94      constructor Create(aOwner: TFB25Events);
95      destructor Destroy; override;
96 <    procedure eventCallbackFunction(length: short; updated: PChar);
96 >    procedure eventCallbackFunction(length: short; updated: PAnsiChar);
97      procedure WaitForEvent;
98      procedure CancelWait;
99   end;
# Line 103 | Line 106 | type
106      FDBHandle: TISC_DB_HANDLE;
107      FEventHandlerThread: TObject;
108      FAsyncEventCallback: TEventhandlerInterface;
109 +    FFirebird25ClientAPI: TFB25ClientAPI;
110    protected
111      procedure CancelEvents(Force: boolean = false); override;
112      function GetIEvents: IEvents; override;
# Line 112 | Line 116 | type
116  
117      {IEvents}
118      procedure WaitForEvent;
119 <    procedure AsyncWaitForEvent(EventHandler: TEventHandler);
119 >    procedure AsyncWaitForEvent(EventHandler: TEventHandler); override;
120    end;
121  
122   implementation
# Line 150 | Line 154 | type
154   constructor TEventHandlerThread.Create(Owner: TFB25Events;
155     EventHandler: TEventhandlerInterface);
156   begin
157 <   inherited Create(true);
157 >   inherited Create(false);
158     FOwner := Owner;
159     FEventHandler := EventHandler;
160     FreeOnTerminate := true;
157   Start;
161   end;
162  
163   procedure TEventHandlerThread.Terminate;
# Line 165 | Line 168 | type
168  
169    {This procedure is used for the event call back - note the cdecl }
170  
171 < procedure IBEventCallback( ptr: pointer; length: short; updated: PChar); cdecl;
171 > procedure IBEventCallback( ptr: pointer; length: short; updated: PAnsiChar); cdecl;
172   begin
173     if (ptr = nil) or (length = 0) or (updated = nil) then
174       Exit;
# Line 195 | Line 198 | begin
198   {$ENDIF}
199    inherited Create;
200   {$IFDEF WINDOWS}
201 <  FEventHandler := CreateEvent(PSa,false,true,nil);
201 >  FEventHandler := CreateEvent(PSa,false,false,nil);
202   {$ELSE}
203    CreateGuid(GUID);
204    FEventWaiting := TEventObject.Create(PSa,false,false,GUIDToString(GUID));
# Line 214 | Line 217 | begin
217   end;
218  
219   procedure TEventhandlerInterface.eventCallbackFunction(length: short;
220 <  updated: PChar);
220 >  updated: PAnsiChar);
221   begin
222    FOwner.FCriticalSection.Enter;
223    try
224      if FOwner.FResultBuffer <> nil then
225        Move(updated[0], FOwner.FResultBuffer[0], length);
223    {$IFDEF WINDOWS}
224    SetEvent(FEventHandler);
225    {$ELSE}
226    FEventWaiting.SetEvent;
227    {$ENDIF}
226    finally
227      FOwner.FCriticalSection.Leave
228    end;
229 + //  writeln('Set Event');
230 +  {$IFDEF WINDOWS}
231 +  SetEvent(FEventHandler);
232 +  {$ELSE}
233 +  FEventWaiting.SetEvent;
234 +  {$ENDIF}
235   end;
236  
237   procedure TEventhandlerInterface.WaitForEvent;
# Line 237 | Line 241 | begin
241    {$ELSE}
242    FEventWaiting.WaitFor(INFINITE);
243    {$ENDIF}
244 + //  writeln('Event Wait Ends');
245   end;
246  
247   procedure TEventhandlerInterface.CancelWait;
# Line 256 | Line 261 | begin
261    FCriticalSection.Enter;
262    try
263      if not FInWaitState then Exit;
264 <    with Firebird25ClientAPI do
264 >    with FFirebird25ClientAPI do
265        if (Call(isc_Cancel_events( StatusVector, @FDBHandle, @FEventID),false) > 0) and not Force then
266          IBDatabaseError;
267  
# Line 276 | Line 281 | constructor TFB25Events.Create(DBAttachm
281   begin
282    inherited Create(DBAttachment,DBAttachment,Events);
283    FDBHandle := DBAttachment.Handle;
284 +  FFirebird25ClientAPI := DBAttachment.Firebird25ClientAPI;
285 +  OnDatabaseError := FFirebird25ClientAPI.IBDataBaseError;
286    FAsyncEventCallback := TEventhandlerInterface.Create(self);
287    FEventHandlerThread := TEventHandlerThread.Create(self,FAsyncEventCallback);
288   end;
# Line 298 | Line 305 | begin
305      if FInWaitState then
306        IBError(ibxeInEventWait,[nil]);
307  
301    CreateEventBlock;
308      FEventHandler := EventHandler;
309      callback := @IBEventCallback;
310 <    with Firebird25ClientAPI do
310 >    with FFirebird25ClientAPI do
311        Call(isc_que_events( StatusVector, @FDBHandle, @FEventID, FEventBufferLen,
312                       FEventBuffer, TISC_CALLBACK(callback), PVoid(FAsyncEventCallback)));
313      FInWaitState := true;
# Line 317 | Line 323 | begin
323  
324    FInWaitState := true;
325    try
326 <    CreateEventBlock;
321 <    with Firebird25ClientAPI do
326 >    with FFirebird25ClientAPI do
327         Call(isc_wait_for_event(StatusVector,@FDBHandle, FEventBufferlen,FEventBuffer,FResultBuffer));
328    finally
329      FInWaitState := false;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines