Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

177 lines
4.6 KiB

  1. #---------------------------------------------------------------------
  2. package Win32::IPC;
  3. #
  4. # Copyright 1998 Christopher J. Madsen
  5. #
  6. # Created: 3 Feb 1998 from the ActiveWare version
  7. # (c) 1995 Microsoft Corporation. All rights reserved.
  8. # Developed by ActiveWare Internet Corp., http://www.ActiveWare.com
  9. #
  10. # Other modifications (c) 1997 by Gurusamy Sarathy <[email protected]>
  11. #
  12. # Author: Christopher J. Madsen <[email protected]>
  13. # Version: 1.00 (6-Feb-1998)
  14. #
  15. # This program is free software; you can redistribute it and/or modify
  16. # it under the same terms as Perl itself.
  17. #
  18. # This program is distributed in the hope that it will be useful,
  19. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See either the
  21. # GNU General Public License or the Artistic License for more details.
  22. #
  23. # Base class for Win32 synchronization objects
  24. #---------------------------------------------------------------------
  25. $VERSION = '1.02';
  26. require Exporter;
  27. require DynaLoader;
  28. use strict;
  29. use vars qw($AUTOLOAD $VERSION @ISA @EXPORT @EXPORT_OK);
  30. @ISA = qw(Exporter DynaLoader);
  31. @EXPORT = qw(
  32. INFINITE
  33. WaitForMultipleObjects
  34. );
  35. @EXPORT_OK = qw(
  36. wait_any wait_all
  37. );
  38. sub AUTOLOAD {
  39. # This AUTOLOAD is used to 'autoload' constants from the constant()
  40. # XS function.
  41. my($constname);
  42. ($constname = $AUTOLOAD) =~ s/.*:://;
  43. my $val = constant($constname);
  44. if ($! != 0) {
  45. my ($pack,$file,$line) = caller;
  46. die "Your vendor has not defined Win32::IPC macro $constname, used at $file line $line.";
  47. }
  48. eval "sub $AUTOLOAD { $val }";
  49. goto &$AUTOLOAD;
  50. } # end AUTOLOAD
  51. bootstrap Win32::IPC;
  52. # How's this for cryptic? Use wait_any or wait_all!
  53. sub WaitForMultipleObjects
  54. {
  55. my $result = (($_[1] ? wait_all($_[0], $_[2])
  56. : wait_any($_[0], $_[2]))
  57. ? 1
  58. : 0);
  59. @{$_[0]} = (); # Bug for bug compatibility! Use wait_any or wait_all!
  60. $result;
  61. } # end WaitForMultipleObjects
  62. 1;
  63. __END__
  64. =head1 NAME
  65. Win32::IPC - Base class for Win32 synchronization objects
  66. =head1 SYNOPSIS
  67. use Win32::Event 1.00 qw(wait_any);
  68. #Create objects.
  69. wait_any(@ListOfObjects,$timeout);
  70. =head1 DESCRIPTION
  71. This module is loaded by the other Win32 synchronization modules. You
  72. shouldn't need to load it yourself. It supplies the wait functions to
  73. those modules.
  74. The synchronization modules are L<"Win32::ChangeNotify">,
  75. L<"Win32::Event">, L<"Win32::Mutex">, & L<"Win32::Semaphore">.
  76. =head2 Methods
  77. B<Win32::IPC> supplies one method to all synchronization objects.
  78. =over 4
  79. =item $obj->wait([$timeout])
  80. Waits for C<$obj> to become signalled. C<$timeout> is the maximum time
  81. to wait (in milliseconds). If C<$timeout> is omitted, waits forever.
  82. If C<$timeout> is 0, returns immediately.
  83. Returns:
  84. +1 The object is signalled
  85. -1 The object is an abandoned mutex
  86. 0 Timed out
  87. undef An error occurred
  88. =back
  89. =head2 Functions
  90. =over 4
  91. =item wait_any(@objects, [$timeout])
  92. Waits for at least one of the C<@objects> to become signalled.
  93. C<$timeout> is the maximum time to wait (in milliseconds). If
  94. C<$timeout> is omitted, waits forever. If C<$timeout> is 0, returns
  95. immediately.
  96. The return value indicates which object ended the wait:
  97. +N $object[N-1] is signalled
  98. -N $object[N-1] is an abandoned mutex
  99. 0 Timed out
  100. undef An error occurred
  101. If more than one object became signalled, the one with the lowest
  102. index is used.
  103. =item wait_all(@objects, [$timeout])
  104. This is the same as C<wait_any>, but it waits for all the C<@objects>
  105. to become signalled. The return value indicates the last object to
  106. become signalled, and is negative if at least one of the C<@objects>
  107. is an abandoned mutex.
  108. =back
  109. =head2 Deprecated Functions and Methods
  110. B<Win32::IPC> still supports the ActiveWare syntax, but its use is
  111. deprecated.
  112. =over 4
  113. =item INFINITE
  114. Constant value for an infinite timeout. Omit the C<$timeout> argument
  115. instead.
  116. =item WaitForMultipleObjects(\@objects, $wait_all, $timeout)
  117. Warning: C<WaitForMultipleObjects> erases C<@objects>!
  118. Use C<wait_all> or C<wait_any> instead.
  119. =item $obj->Wait($timeout)
  120. Similar to C<not $obj-E<gt>wait($timeout)>.
  121. =back
  122. =head1 AUTHOR
  123. Christopher J. Madsen E<lt>F<[email protected]>E<gt>
  124. Loosely based on the original module by ActiveWare Internet Corp.,
  125. F<http://www.ActiveWare.com>
  126. =cut
  127. # Local Variables:
  128. # tmtrack-file-task: "Win32::IPC"
  129. # End: