|
@@ -2,9 +2,11 @@
|
|
$Id$
|
|
$Id$
|
|
|
|
|
|
fpAsync: Asynchronous event management for Free Pascal
|
|
fpAsync: Asynchronous event management for Free Pascal
|
|
- Copyright (C) 2001-2003 by
|
|
|
|
|
|
+ Copyright (C) 2001-2002 by
|
|
Areca Systems GmbH / Sebastian Guenther, [email protected]
|
|
Areca Systems GmbH / Sebastian Guenther, [email protected]
|
|
|
|
|
|
|
|
+ Unix implementation
|
|
|
|
+
|
|
See the file COPYING.FPC, included in this distribution,
|
|
See the file COPYING.FPC, included in this distribution,
|
|
for details about the copyright.
|
|
for details about the copyright.
|
|
|
|
|
|
@@ -174,7 +176,6 @@ type
|
|
FDataStream: TStream;
|
|
FDataStream: TStream;
|
|
FBlockingStream: THandleStream;
|
|
FBlockingStream: THandleStream;
|
|
NotifyHandle: Pointer;
|
|
NotifyHandle: Pointer;
|
|
- DoStopAndFree: Boolean;
|
|
|
|
|
|
|
|
function DoRealWrite(const ABuffer; Count: Integer): Integer; override;
|
|
function DoRealWrite(const ABuffer; Count: Integer): Integer; override;
|
|
procedure WritingFailed; override;
|
|
procedure WritingFailed; override;
|
|
@@ -186,7 +187,6 @@ type
|
|
constructor Create(AEventLoop: TEventLoop;
|
|
constructor Create(AEventLoop: TEventLoop;
|
|
ADataStream: TStream; ABlockingStream: THandleStream);
|
|
ADataStream: TStream; ABlockingStream: THandleStream);
|
|
destructor Destroy; override;
|
|
destructor Destroy; override;
|
|
- procedure StopAndFree; // Destroy instance after run
|
|
|
|
|
|
|
|
property EventLoop: TEventLoop read FEventLoop;
|
|
property EventLoop: TEventLoop read FEventLoop;
|
|
property DataStream: TStream read FDataStream;
|
|
property DataStream: TStream read FDataStream;
|
|
@@ -194,12 +194,6 @@ type
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
-var
|
|
|
|
- { All data written to a TWriteBuffer or descendant class will be written to
|
|
|
|
- this stream as well: }
|
|
|
|
- fpAsyncWriteBufferDebugStream: TStream;
|
|
|
|
-
|
|
|
|
-
|
|
|
|
implementation
|
|
implementation
|
|
|
|
|
|
type
|
|
type
|
|
@@ -595,16 +589,13 @@ end;
|
|
|
|
|
|
destructor TAsyncStreamLineReader.Destroy;
|
|
destructor TAsyncStreamLineReader.Destroy;
|
|
begin
|
|
begin
|
|
|
|
+ if Assigned(NotifyHandle) then
|
|
|
|
+ EventLoop.ClearDataAvailableNotify(NotifyHandle);
|
|
inherited Destroy;
|
|
inherited Destroy;
|
|
end;
|
|
end;
|
|
|
|
|
|
procedure TAsyncStreamLineReader.StopAndFree;
|
|
procedure TAsyncStreamLineReader.StopAndFree;
|
|
begin
|
|
begin
|
|
- if Assigned(NotifyHandle) then
|
|
|
|
- begin
|
|
|
|
- EventLoop.ClearDataAvailableNotify(NotifyHandle);
|
|
|
|
- NotifyHandle := nil;
|
|
|
|
- end;
|
|
|
|
DoStopAndFree := True;
|
|
DoStopAndFree := True;
|
|
end;
|
|
end;
|
|
|
|
|
|
@@ -683,8 +674,6 @@ begin
|
|
ReallocMem(FBuffer, FBytesInBuffer + Count);
|
|
ReallocMem(FBuffer, FBytesInBuffer + Count);
|
|
Move(ABuffer, FBuffer[FBytesInBuffer], Count);
|
|
Move(ABuffer, FBuffer[FBytesInBuffer], Count);
|
|
Inc(FBytesInBuffer, Count);
|
|
Inc(FBytesInBuffer, Count);
|
|
- if Assigned(fpAsyncWriteBufferDebugStream) then
|
|
|
|
- fpAsyncWriteBufferDebugStream.Write(ABuffer, Count);
|
|
|
|
WantWrite;
|
|
WantWrite;
|
|
Result := Count;
|
|
Result := Count;
|
|
end;
|
|
end;
|
|
@@ -768,8 +757,6 @@ end;
|
|
procedure TAsyncWriteStream.CanWrite(UserData: TObject);
|
|
procedure TAsyncWriteStream.CanWrite(UserData: TObject);
|
|
begin
|
|
begin
|
|
Run;
|
|
Run;
|
|
- if DoStopAndFree then
|
|
|
|
- Free;
|
|
|
|
end;
|
|
end;
|
|
|
|
|
|
constructor TAsyncWriteStream.Create(AEventLoop: TEventLoop;
|
|
constructor TAsyncWriteStream.Create(AEventLoop: TEventLoop;
|
|
@@ -796,27 +783,13 @@ begin
|
|
inherited Destroy;
|
|
inherited Destroy;
|
|
end;
|
|
end;
|
|
|
|
|
|
-procedure TAsyncWriteStream.StopAndFree;
|
|
|
|
-begin
|
|
|
|
- if Assigned(NotifyHandle) then
|
|
|
|
- begin
|
|
|
|
- EventLoop.ClearCanWriteNotify(NotifyHandle);
|
|
|
|
- NotifyHandle := nil;
|
|
|
|
- end;
|
|
|
|
- DoStopAndFree := True;
|
|
|
|
-end;
|
|
|
|
-
|
|
|
|
|
|
|
|
end.
|
|
end.
|
|
|
|
|
|
|
|
|
|
{
|
|
{
|
|
$Log$
|
|
$Log$
|
|
- Revision 1.2 2002-04-25 19:12:27 sg
|
|
|
|
- * Added ability to write all write buffer data to an debug stream
|
|
|
|
- * Added TAsyncWriteStream.StopAndFree
|
|
|
|
-
|
|
|
|
- Revision 1.1 2003/03/17 22:25:32 michael
|
|
|
|
|
|
+ Revision 1.1 2003-03-17 22:25:32 michael
|
|
+ Async moved from package to FCL
|
|
+ Async moved from package to FCL
|
|
|
|
|
|
Revision 1.3 2002/09/15 15:45:38 sg
|
|
Revision 1.3 2002/09/15 15:45:38 sg
|