libasync.inc 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. {
  2. $Id$
  3. libasync: Asynchronous event management
  4. Copyright (C) 2001 by
  5. Areca Systems GmbH / Sebastian Guenther, [email protected]
  6. Common interface declaration
  7. See the file COPYING.FPC, included in this distribution,
  8. for details about the copyright.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  12. }
  13. type
  14. TAsyncHandleStruct = packed record
  15. UserData: Pointer;
  16. Data: TAsyncData;
  17. end;
  18. TAsyncHandle = ^TAsyncHandleStruct;
  19. TAsyncTimer = Pointer;
  20. TAsyncCallback = procedure(UserData: Pointer); cdecl;
  21. // Construction and destruction
  22. procedure asyncInit(
  23. Handle: TAsyncHandle); cdecl;
  24. procedure asyncFree(
  25. Handle: TAsyncHandle); cdecl;
  26. // Running and stopping the event loop
  27. procedure asyncRun(
  28. Handle: TAsyncHandle); cdecl;
  29. procedure asyncBreak(
  30. Handle: TAsyncHandle); cdecl;
  31. // Status information
  32. function asyncIsRunning(
  33. Handle: TAsyncHandle
  34. ): Boolean; cdecl;
  35. function asyncGetTicks: Int64; cdecl;
  36. // Timer management
  37. function asyncAddTimer(
  38. Handle: TAsyncHandle;
  39. MSec: LongInt;
  40. Periodic: Boolean; // False = One-shot timer, True = Periodic timer
  41. Callback: TAsyncCallback;
  42. UserData: Pointer // User data for callback
  43. ): TAsyncTimer; cdecl;
  44. procedure asyncRemoveTimer(
  45. Handle: TAsyncHandle;
  46. Timer: TASyncTimer); cdecl;
  47. // I/O callback management
  48. procedure asyncSetIOCallback(
  49. Handle: TAsyncHandle;
  50. IOHandle: LongInt;
  51. Callback: TAsyncCallback;
  52. UserData: Pointer); cdecl;
  53. procedure asyncClearIOCallback(
  54. Handle: TAsyncHandle;
  55. IOHandle: LongInt); cdecl;
  56. procedure asyncSetDataAvailableCallback(
  57. Handle: TAsyncHandle;
  58. IOHandle: LongInt;
  59. Callback: TAsyncCallback;
  60. UserData: Pointer); cdecl;
  61. procedure asyncClearDataAvailableCallback(
  62. Handle: TAsyncHandle;
  63. IOHandle: LongInt); cdecl;
  64. procedure asyncSetCanWriteCallback(
  65. Handle: TAsyncHandle;
  66. IOHandle: LongInt;
  67. Callback: TAsyncCallback;
  68. UserData: Pointer); cdecl;
  69. procedure asyncClearCanWriteCallback(
  70. Handle: TAsyncHandle;
  71. IOHandle: LongInt); cdecl;
  72. {
  73. $Log$
  74. Revision 1.2 2001-12-11 17:45:28 marco
  75. * was only commited to fixes.
  76. Revision 1.1.2.2 2001/11/16 12:51:41 sg
  77. * Now different handlers for available data and space in write buffer can
  78. be set
  79. * LOTS of bugfixes in the implementation
  80. * fpAsync now has a write buffer class (a read buffer class for reading
  81. line by line will be included in the next release)
  82. Revision 1.1.2.1 2001/09/08 15:43:24 sg
  83. * First public version
  84. }