Browse Source

+ Async moved from package to FCL

michael 22 years ago
parent
commit
0ad4bad79c
3 changed files with 36 additions and 36 deletions
  1. 28 1
      fcl/Makefile
  2. 2 2
      fcl/Makefile.fpc
  3. 6 33
      fcl/inc/fpasync.pp

+ 28 - 1
fcl/Makefile

@@ -217,7 +217,7 @@ override PACKAGE_VERSION=1.0.6
 override TARGET_DIRS+=xml db shedit passrc
 override TARGET_DIRS+=xml db shedit passrc
 override TARGET_UNITS+=classes contnrs inifiles ezcgi pipes rtfpars idea base64 gettext iostream zstream cachecls xmlreg registry eventlog
 override TARGET_UNITS+=classes contnrs inifiles ezcgi pipes rtfpars idea base64 gettext iostream zstream cachecls xmlreg registry eventlog
 ifeq ($(OS_TARGET),linux)
 ifeq ($(OS_TARGET),linux)
-override TARGET_UNITS+=process asyncio resolve ssockets http
+override TARGET_UNITS+=process asyncio resolve ssockets http fpasync
 endif
 endif
 ifeq ($(OS_TARGET),win32)
 ifeq ($(OS_TARGET),win32)
 override TARGET_UNITS+=process fileinfo resolve ssockets
 override TARGET_UNITS+=process fileinfo resolve ssockets
@@ -826,6 +826,7 @@ ifeq ($(OS_TARGET),linux)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_PASZLIB=1
 REQUIRE_PACKAGES_PASZLIB=1
 REQUIRE_PACKAGES_NETDB=1
 REQUIRE_PACKAGES_NETDB=1
+REQUIRE_PACKAGES_LIBASYNC=1
 REQUIRE_PACKAGES_MYSQL=1
 REQUIRE_PACKAGES_MYSQL=1
 REQUIRE_PACKAGES_IBASE=1
 REQUIRE_PACKAGES_IBASE=1
 endif
 endif
@@ -971,6 +972,32 @@ ifdef UNITDIR_NETDB
 override COMPILER_UNITDIR+=$(UNITDIR_NETDB)
 override COMPILER_UNITDIR+=$(UNITDIR_NETDB)
 endif
 endif
 endif
 endif
+ifdef REQUIRE_PACKAGES_LIBASYNC
+PACKAGEDIR_LIBASYNC:=$(firstword $(subst /Makefile.fpc,,$(strip $(wildcard $(addsuffix /libasync/Makefile.fpc,$(PACKAGESDIR))))))
+ifneq ($(PACKAGEDIR_LIBASYNC),)
+ifneq ($(wildcard $(PACKAGEDIR_LIBASYNC)/$(OS_TARGET)),)
+UNITDIR_LIBASYNC=$(PACKAGEDIR_LIBASYNC)/$(OS_TARGET)
+else
+UNITDIR_LIBASYNC=$(PACKAGEDIR_LIBASYNC)
+endif
+ifdef CHECKDEPEND
+$(PACKAGEDIR_LIBASYNC)/$(FPCMADE):
+	$(MAKE) -C $(PACKAGEDIR_LIBASYNC) $(FPCMADE)
+override ALLDEPENDENCIES+=$(PACKAGEDIR_LIBASYNC)/$(FPCMADE)
+endif
+else
+PACKAGEDIR_LIBASYNC=
+UNITDIR_LIBASYNC:=$(subst /Package.fpc,,$(strip $(wildcard $(addsuffix /libasync/Package.fpc,$(UNITSDIR)))))
+ifneq ($(UNITDIR_LIBASYNC),)
+UNITDIR_LIBASYNC:=$(firstword $(UNITDIR_LIBASYNC))
+else
+UNITDIR_LIBASYNC=
+endif
+endif
+ifdef UNITDIR_LIBASYNC
+override COMPILER_UNITDIR+=$(UNITDIR_LIBASYNC)
+endif
+endif
 ifdef REQUIRE_PACKAGES_MYSQL
 ifdef REQUIRE_PACKAGES_MYSQL
 PACKAGEDIR_MYSQL:=$(firstword $(subst /Makefile.fpc,,$(strip $(wildcard $(addsuffix /mysql/Makefile.fpc,$(PACKAGESDIR))))))
 PACKAGEDIR_MYSQL:=$(firstword $(subst /Makefile.fpc,,$(strip $(wildcard $(addsuffix /mysql/Makefile.fpc,$(PACKAGESDIR))))))
 ifneq ($(PACKAGEDIR_MYSQL),)
 ifneq ($(PACKAGEDIR_MYSQL),)

+ 2 - 2
fcl/Makefile.fpc

@@ -8,7 +8,7 @@ version=1.0.6
 
 
 [require]
 [require]
 packages=paszlib
 packages=paszlib
-packages_linux=netdb
+packages_linux=netdb libasync
 packages_freebsd=netdb
 packages_freebsd=netdb
 packages_netbsd=netdb
 packages_netbsd=netdb
 packages_openbsd=netdb
 packages_openbsd=netdb
@@ -24,7 +24,7 @@ units=classes contnrs inifiles ezcgi pipes rtfpars idea base64 gettext iostream
 units_freebsd=process asyncio ssockets http resolve http
 units_freebsd=process asyncio ssockets http resolve http
 units_netbsd=process asyncio ssockets http resolve http
 units_netbsd=process asyncio ssockets http resolve http
 units_openbsd=process asyncio ssockets http resolve http
 units_openbsd=process asyncio ssockets http resolve http
-units_linux=process asyncio resolve ssockets http
+units_linux=process asyncio resolve ssockets http fpasync
 units_win32=process fileinfo resolve ssockets
 units_win32=process fileinfo resolve ssockets
 rsts=classes ssockets cachecls resolve
 rsts=classes ssockets cachecls resolve
 exampledirs=tests
 exampledirs=tests

+ 6 - 33
fcl/inc/fpasync.pp

@@ -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