Pthreads: document Threaded::notifyOne

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@342864 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Thomas Punt 2017-08-17 12:41:05 +00:00
parent 12a490459d
commit db8cca3a2a
2 changed files with 96 additions and 0 deletions

View file

@ -0,0 +1,93 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="threaded.notifyone" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>Threaded::notifyOne</refname>
<refpurpose>Synchronization</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <type>boolean</type><methodname>Threaded::notifyOne</methodname>
<void />
</methodsynopsis>
<para>
Send notification to the referenced object. This unblocks at least one of the
blocked threads (as opposed to unblocking all of them, as seen with
<methodname>Threaded::notify</methodname>).
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
&no.function.parameters;
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
A boolean indication of success
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Notifications and Waiting</title>
<programlisting role="php">
<![CDATA[
<?php
class My extends Thread {
public function run() {
/** cause this thread to wait **/
$this->synchronized(function($thread){
if (!$thread->done)
$thread->wait();
}, $this);
}
}
$my = new My();
$my->start();
/** send notification to the waiting thread **/
$my->synchronized(function($thread){
$thread->done = true;
$thread->notifyOne();
}, $my);
var_dump($my->join());
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
bool(true)
]]>
</screen>
</example>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->

View file

@ -11,6 +11,7 @@
<function name='threaded::run' from='PECL pthreads &gt;= 2.0.0'/>
<function name='threaded::wait' from='PECL pthreads &gt;= 2.0.0'/>
<function name='threaded::notify' from='PECL pthreads &gt;= 2.0.0'/>
<function name='threaded::notifyone' from='PECL pthreads &gt;= 3.0.0'/>
<function name='threaded::isrunning' from='PECL pthreads &gt;= 2.0.0'/>
<function name='threaded::iswaiting' from='PECL pthreads &lt; 3.0.0'/>
<function name='threaded::isterminated' from='PECL pthreads &gt;= 2.0.0'/>
@ -40,6 +41,7 @@
<function name='thread::run' from='PECL pthreads &gt;= 2.0.0'/>
<function name='thread::wait' from='PECL pthreads &gt;= 2.0.0'/>
<function name='thread::notify' from='PECL pthreads &gt;= 2.0.0'/>
<function name='threaded::notifyone' from='PECL pthreads &gt;= 3.0.0'/>
<function name='thread::isrunning' from='PECL pthreads &gt;= 2.0.0'/>
<function name='thread::iswaiting' from='PECL pthreads &lt; 3.0.0'/>
<function name='thread::isterminated' from='PECL pthreads &gt;= 2.0.0'/>
@ -75,6 +77,7 @@
<function name='worker::run' from='PECL pthreads &gt;= 2.0.0'/>
<function name='worker::wait' from='PECL pthreads &gt;= 2.0.0'/>
<function name='worker::notify' from='PECL pthreads &gt;= 2.0.0'/>
<function name='threaded::notifyone' from='PECL pthreads &gt;= 3.0.0'/>
<function name='worker::isrunning' from='PECL pthreads &gt;= 2.0.0'/>
<function name='worker::iswaiting' from='PECL pthreads &lt; 3.0.0'/>
<function name='worker::isterminated' from='PECL pthreads &gt;= 2.0.0'/>