34 |
|
{$interfaces COM} |
35 |
|
{$ENDIF} |
36 |
|
|
37 |
+ |
{ $DEFINE EVENTDEBUG} |
38 |
+ |
|
39 |
|
interface |
40 |
|
|
41 |
|
uses |
138 |
|
FOWner := aOwner; |
139 |
|
FName := aName; |
140 |
|
addRef; |
141 |
+ |
{$IFDEF EVENTDEBUG} writeln(FName,' TEventhandlerInterface: Create'); {$ENDIF} |
142 |
|
end; |
143 |
|
|
144 |
|
destructor TEventhandlerInterface.Destroy; |
148 |
|
{$ELSE} |
149 |
|
if assigned(FEventWaiting) then FEventWaiting.Free; |
150 |
|
{$ENDIF} |
151 |
+ |
{$IFDEF EVENTDEBUG} writeln(FName,' TEventhandlerInterface: Destroy'); {$ENDIF} |
152 |
|
inherited Destroy; |
153 |
|
end; |
154 |
|
|
155 |
|
procedure TEventhandlerInterface.addRef; |
156 |
|
begin |
157 |
|
Inc(FRef); |
158 |
< |
// writeln(FName,': ref count = ',FRef); |
158 |
> |
{$IFDEF EVENTDEBUG} writeln(FName,': ref count = ',FRef);{$ENDIF} |
159 |
|
end; |
160 |
|
|
161 |
|
function TEventhandlerInterface.release: Integer; |
162 |
|
begin |
163 |
|
Dec(FRef); |
164 |
< |
// writeln(FName,': ref count = ',FRef); |
164 |
> |
{$IFDEF EVENTDEBUG} writeln(FName,': ref count = ',FRef);{$ENDIF} |
165 |
|
if FRef = 0 then Free; |
166 |
|
Result := FRef; |
167 |
|
end; |
169 |
|
procedure TEventhandlerInterface.eventCallbackFunction(length: Cardinal; |
170 |
|
events: BytePtr); |
171 |
|
begin |
172 |
< |
// writeln('TEventhandlerInterface: Event Callback'); |
172 |
> |
{$IFDEF EVENTDEBUG} writeln(FName,' TEventhandlerInterface: Event Callback'); {$ENDIF} |
173 |
|
FOwner.FCriticalSection.Enter; |
174 |
|
try |
175 |
|
if FOwner.FResultBuffer <> nil then |
177 |
|
finally |
178 |
|
FOwner.FCriticalSection.Leave |
179 |
|
end; |
180 |
< |
//writeln('TEventhandlerInterface: Set Event Called'); |
180 |
> |
{$IFDEF EVENTDEBUG}writeln(FName,' TEventhandlerInterface: Set Event Called'); {$ENDIF} |
181 |
|
{$IFDEF WINDOWS} |
182 |
|
SetEvent(FEventHandler); |
183 |
|
{$ELSE} |
187 |
|
|
188 |
|
procedure TEventhandlerInterface.WaitForEvent; |
189 |
|
begin |
190 |
< |
// writeln('TEventhandlerInterface: Start Event Wait'); |
190 |
> |
{$IFDEF EVENTDEBUG} writeln(FName,' TEventhandlerInterface: Start Event Wait'); {$ENDIF} |
191 |
|
{$IFDEF WINDOWS} |
192 |
|
WaitForSingleObject(FEventHandler,INFINITE); |
193 |
|
{$ELSE} |
194 |
|
FEventWaiting.WaitFor(INFINITE); |
195 |
|
{$ENDIF} |
196 |
< |
// writeln('TEventhandlerInterface: Event Wait Ends'); |
196 |
> |
{$IFDEF EVENTDEBUG} writeln(FName,' TEventhandlerInterface: Event Wait Ends');{$ENDIF} |
197 |
|
end; |
198 |
|
|
199 |
|
procedure TEventhandlerInterface.CancelWait; |
209 |
|
|
210 |
|
procedure TEventHandlerThread.Execute; |
211 |
|
begin |
212 |
+ |
{$IFDEF EVENTDEBUG} writeln('Event Handler Thread Starts'); {$ENDIF} |
213 |
|
while not Terminated do |
214 |
|
begin |
215 |
|
FEventHandler.WaitForEvent; |
216 |
+ |
{$IFDEF EVENTDEBUG} writeln('Event Handler Ends Wait ',Terminated); {$ENDIF} |
217 |
|
|
218 |
|
if not Terminated then |
219 |
|
FOwner.EventSignaled; |
220 |
|
end; |
221 |
+ |
{$IFDEF EVENTDEBUG} writeln('Event Handler Thread Ends'); {$ENDIF} |
222 |
|
end; |
223 |
|
|
224 |
|
constructor TEventHandlerThread.Create(Owner: TFB30Events; |
234 |
|
begin |
235 |
|
inherited Terminate; |
236 |
|
FEventHandler.CancelWait; |
237 |
+ |
{$IFDEF EVENTDEBUG} writeln('Event Handler Thread Cancelled'); {$ENDIF} |
238 |
|
end; |
239 |
|
|
240 |
|
{ TFB30Events } |