ipc.html

来自「perl教程」· HTML 代码 · 共 181 行

HTML
181
字号
<?xml version="1.0" ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<!-- saved from url=(0017)http://localhost/ -->
<script language="JavaScript" src="../../displayToc.js"></script>
<script language="JavaScript" src="../../tocParas.js"></script>
<script language="JavaScript" src="../../tocTab.js"></script>
<link rel="stylesheet" type="text/css" href="../../scineplex.css">
<title>Win32::IPC - Base class for Win32 synchronization objects</title>
<link rel="stylesheet" href="../../Active.css" type="text/css" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rev="made" href="mailto:" />
</head>

<body>

<script>writelinks('__top__',2);</script>
<h1><a>Win32::IPC - Base class for Win32 synchronization objects</a></h1>
<p><a name="__index__"></a></p>

<!-- INDEX BEGIN -->

<ul>

	<li><a href="#name">NAME</a></li>
	<li><a href="#synopsis">SYNOPSIS</a></li>
	<li><a href="#description">DESCRIPTION</a></li>
	<ul>

		<li><a href="#methods">Methods</a></li>
		<li><a href="#functions">Functions</a></li>
		<li><a href="#deprecated_functions_and_methods">Deprecated Functions and Methods</a></li>
	</ul>

	<li><a href="#internals">INTERNALS</a></li>
	<li><a href="#author">AUTHOR</a></li>
</ul>
<!-- INDEX END -->

<hr />
<p>
</p>
<h1><a name="name">NAME</a></h1>
<p>Win32::IPC - Base class for Win32 synchronization objects</p>
<p>
</p>
<hr />
<h1><a name="synopsis">SYNOPSIS</a></h1>
<pre>
    <span class="keyword">use</span> <span class="variable">Win32::Event</span> <span class="number">1.00</span> <span class="string">qw(wait_any)</span><span class="operator">;</span>
    <span class="comment">#Create objects.</span>
</pre>
<pre>
    <span class="variable">wait_any</span><span class="operator">(</span><span class="variable">@ListOfObjects</span><span class="operator">,</span><span class="variable">$timeout</span><span class="operator">);</span>
</pre>
<p>
</p>
<hr />
<h1><a name="description">DESCRIPTION</a></h1>
<p>This module is loaded by the other Win32 synchronization modules.  You
shouldn't need to load it yourself.  It supplies the wait functions to
those modules.</p>
<p>The synchronization modules are <a href="#win32__changenotify">Win32::ChangeNotify</a>,
<a href="#win32__event">Win32::Event</a>, <a href="#win32__mutex">Win32::Mutex</a>, &amp; <a href="#win32__semaphore">Win32::Semaphore</a>.</p>
<p>In addition, you can use <a href="#item_wait_any"><code>wait_any</code></a> and <a href="#item_wait_all"><code>wait_all</code></a> with
<a href="#win32__console">Win32::Console</a> and <a href="#win32__process">Win32::Process</a> objects.  (However, those
modules do not export the wait functions; you must load one of the
synchronization modules (or just Win32::IPC)).</p>
<p>
</p>
<h2><a name="methods">Methods</a></h2>
<p><strong>Win32::IPC</strong> supplies one method to all synchronization objects.</p>
<dl>
<dt><strong><a name="item_wait">$obj-&gt;<code>wait([$timeout])</code></a></strong>

<dd>
<p>Waits for <code>$obj</code> to become signalled.  <code>$timeout</code> is the maximum time
to wait (in milliseconds).  If <code>$timeout</code> is omitted, waits forever.
If <code>$timeout</code> is 0, returns immediately.</p>
</dd>
<dd>
<p>Returns:</p>
</dd>
<dd>
<pre>
   +1    The object is signalled
   -1    The object is an abandoned mutex
    0    Timed out
  undef  An error occurred</pre>
</dd>
</li>
</dl>
<p>
</p>
<h2><a name="functions">Functions</a></h2>
<dl>
<dt><strong><a name="item_wait_any">wait_any(@objects, [$timeout])</a></strong>

<dd>
<p>Waits for at least one of the <code>@objects</code> to become signalled.
<code>$timeout</code> is the maximum time to wait (in milliseconds).  If
<code>$timeout</code> is omitted, waits forever.  If <code>$timeout</code> is 0, returns
immediately.</p>
</dd>
<dd>
<p>The return value indicates which object ended the wait:</p>
</dd>
<dd>
<pre>
   +N    $object[N-1] is signalled
   -N    $object[N-1] is an abandoned mutex
    0    Timed out
  undef  An error occurred</pre>
</dd>
<dd>
<p>If more than one object became signalled, the one with the lowest
index is used.</p>
</dd>
</li>
<dt><strong><a name="item_wait_all">wait_all(@objects, [$timeout])</a></strong>

<dd>
<p>This is the same as <a href="#item_wait_any"><code>wait_any</code></a>, but it waits for all the <code>@objects</code>
to become signalled.  The return value indicates the last object to
become signalled, and is negative if at least one of the <code>@objects</code>
is an abandoned mutex.</p>
</dd>
</li>
</dl>
<p>
</p>
<h2><a name="deprecated_functions_and_methods">Deprecated Functions and Methods</a></h2>
<p><strong>Win32::IPC</strong> still supports the ActiveWare syntax, but its use is
deprecated.</p>
<dl>
<dt><strong><a name="item_infinite">INFINITE</a></strong>

<dd>
<p>Constant value for an infinite timeout.  Omit the <code>$timeout</code> argument
instead.</p>
</dd>
</li>
<dt><strong><a name="item_waitformultipleobjects">WaitForMultipleObjects(\@objects, $wait_all, $timeout)</a></strong>

<dd>
<p>Warning: <a href="#item_waitformultipleobjects"><code>WaitForMultipleObjects</code></a> erases <code>@objects</code>!
Use <a href="#item_wait_all"><code>wait_all</code></a> or <a href="#item_wait_any"><code>wait_any</code></a> instead.</p>
</dd>
</li>
<dt><strong><a name="item_wait">$obj-&gt;<code>Wait($timeout)</code></a></strong>

<dd>
<p>Similar to <a href="#item_wait"><code>not $obj-&gt;wait($timeout)</code></a>.</p>
</dd>
</li>
</dl>
<p>
</p>
<hr />
<h1><a name="internals">INTERNALS</a></h1>
<p>The <a href="#item_wait_any"><code>wait_any</code></a> and <a href="#item_wait_all"><code>wait_all</code></a> functions support two kinds of
objects.  Objects derived from <code>Win32::IPC</code> are expected to consist
of a reference to a scalar containing the Win32 HANDLE as an IV.</p>
<p>Other objects (for which <code>UNIVERSAL::isa($object, &quot;Win32::IPC&quot;)</code> is
false), are expected to implement a <code>get_Win32_IPC_HANDLE</code> method.
When called in scalar context with no arguments, this method should
return a Win32 HANDLE (as an IV) suitable for passing to the Win32
WaitForMultipleObjects API function.</p>
<p>
</p>
<hr />
<h1><a name="author">AUTHOR</a></h1>
<p>Christopher J. Madsen &lt;<em><a href="mailto:cjm@pobox.com">cjm@pobox.com</a></em>&gt;</p>
<p>Loosely based on the original module by ActiveWare Internet Corp.,
<em><a href="http://www.ActiveWare.com">http://www.ActiveWare.com</a></em></p>

</body>

</html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?