1
0
mirror of https://github.com/php/doc-en.git synced 2026-03-24 07:42:10 +01:00

updates for 0.43 API

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@329926 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Joe Watkins
2013-03-26 11:50:59 +00:00
parent 1d2b598616
commit 323cb7d9b9
8 changed files with 329 additions and 18 deletions

View File

@@ -27,12 +27,12 @@
</para>
<para>
A Stackable Object:
A Stackable Object can read/write and execute the Worker ( $this->worker ) during the execution of it's run method.
A Stackable Object can read/write and execute the Worker during execution, simply provide the stackable a reference to the appropriate object before runtime.
Additionally, any context with a reference to the Stackable can read, write and execute it's methods before during and after execution.
</para>
<para>
Synchronization:
All of the objects that pthreads creates have built in synchronization in the form of ::wait and ::notify.
All of the objects that pthreads creates have built in synchronization in the ( familiar to java programmers ) form of ::wait and ::notify.
Calling ::wait on an object will cause the context to wait for another context to call ::notify on the same object.
This allows for powerful synchronization between Threaded Objects in PHP.
</para>
@@ -56,6 +56,15 @@
With the exception of Threaded Objects any reference used to set a member of a Threaded Object is separated from the reference in the Threaded Object;
the same data can be read directly from the Threaded Object at any time by any context with a reference to the Threaded Object.
</para>
<para>
Static Members:
When a new context is created ( Thread or Worker ), only the simple members of static classes are copied, no resources or objects are copied into the threading context from static class members. This allows them to function as a kind of thread local storage. For example, upon starting the context, a class whose static members include connection information for a database server, and the connection itself, will only have the simple connection information copied, not the connection. Allowing the new context to initiate a connection in the same way as the context that created it, storing the connection in the same place without affecting the original context.
</para>
<caution>
<para>
When print_r, var_dump and other object debug functions are executed, they do not include recursion protection.
</para>
</caution>
<note>
<para>
Resources:
@@ -72,6 +81,7 @@
</preface>
&reference.pthreads.setup;
&reference.pthreads.constants;
&reference.pthreads.thread;
&reference.pthreads.worker;
&reference.pthreads.stackable;
@@ -100,4 +110,4 @@ End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->
-->

View File

@@ -0,0 +1,108 @@
<?xml version="1.0" encoding="utf-8"?>
<appendix xml:id="pthreads.constants" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
&reftitle.constants;
&extension.constants;
<para>
The following constants are for selective inheritance:
</para>
<variablelist>
<varlistentry xml:id="constant.pthreads_inherit_all">
<term>
<constant>PTHREADS_INHERIT_ALL</constant>
(<type>integer</type>)
</term>
<listitem>
<simpara>
The default inheritance mask used when starting Threads and Workers
</simpara>
</listitem>
</varlistentry>
<varlistentry xml:id="constant.pthreads_inherit_ini">
<term>
<constant>PTHREADS_INHERIT_INI</constant>
(<type>integer</type>)
</term>
<listitem>
<simpara>
Determines wether the ini entries are inherited by the new context
</simpara>
</listitem>
</varlistentry>
<varlistentry xml:id="constant.pthreads_inherit_constants">
<term>
<constant>PTHREADS_INHERIT_CONSTANTS</constant>
(<type>integer</type>)
</term>
<listitem>
<simpara>
Determines wether the constants are inherited by the new context
</simpara>
</listitem>
</varlistentry>
<varlistentry xml:id="constant.pthreads_inherit_classes">
<term>
<constant>PTHREADS_INHERIT_CLASSES</constant>
(<type>integer</type>)
</term>
<listitem>
<simpara>
Determines wether the class table is inherited by the new context
</simpara>
</listitem>
</varlistentry>
<varlistentry xml:id="constant.pthreads_inherit_functions">
<term>
<constant>PTHREADS_INHERIT_FUNCTIONS</constant>
(<type>integer</type>)
</term>
<listitem>
<simpara>
Determines wether the function table is inherited by the new context
</simpara>
</listitem>
</varlistentry>
<varlistentry xml:id="constant.pthreads_inherit_includes">
<term>
<constant>PTHREADS_INHERIT_INCLUDES</constant>
(<type>integer</type>)
</term>
<listitem>
<simpara>
Determines wether the included_files table is inherit by the new context
</simpara>
</listitem>
</varlistentry>
<varlistentry xml:id="constant.pthreads_inherit_all">
<term>
<constant>PTHREADS_INHERIT_NONE</constant>
(<type>integer</type>)
</term>
<listitem>
<simpara>
Nothing will be inherited by the new context
</simpara>
</listitem>
</varlistentry>
</variablelist>
</appendix>
<!-- 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

@@ -13,12 +13,7 @@
<section xml:id="pthreads.installation">
&reftitle.install;
<para>
To enable pthreads support, configure PHP with <option role="configure">--enable-maintainer-zts</option> and <option role="configure">--enable-pthreads</option>
</para>
<para>
Windows users can download prebuilt binaries from GitHub or from PECL Windows.
</para>
&reference.pthreads.entities.configure;
</section>
<section xml:id="pthreads.configuration">
@@ -28,7 +23,9 @@
<section xml:id="pthreads.resources">
&reftitle.resources;
&no.resource;
<para>
</para>
</section>
</chapter>

View File

@@ -0,0 +1,93 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="stackable.isterminated" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>Stackable::isTerminated</refname>
<refpurpose>State Detection</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>final</modifier> <modifier>public</modifier> <type>boolean</type><methodname>Stackable::isTerminated</methodname>
<void />
</methodsynopsis>
<para>
Tell if the referenced Stackable suffered uncaught exceptions or fatal errors during execution
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
&no.function.parameters;
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
A boolean indication of state
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Detect the state of the referenced Stackable</title>
<programlisting role="php">
<![CDATA[
<?php
class Work extends Stackable {
public function run() {
i_do_not_exist();
}
}
class My extends Worker {
public function run() {
/** ... **/
}
}
$my = new My();
$work = new Work();
$my->stack($work);
$my->start();
$my->shutdown();
var_dump($work->isTerminated());
?>
]]>
</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

@@ -0,0 +1,83 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="thread.isterminated" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>Thread::isTerminated</refname>
<refpurpose>State Detection</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>final</modifier> <modifier>public</modifier> <type>boolean</type><methodname>Thread::isTerminated</methodname>
<void />
</methodsynopsis>
<para>
Tell if the referenced Thread suffered fatal errors or uncaught exceptions during execution
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
&no.function.parameters;
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
A boolean indication of state
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Detect the state of the referenced Thread</title>
<programlisting role="php">
<![CDATA[
<?php
class My extends Thread {
public function run() {
i_do_not_exist();
}
}
$my = new My();
$my->start();
$my->join();
var_dump($my->isTerminated());
?>
]]>
</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,7 +11,7 @@
&reftitle.description;
<methodsynopsis>
<modifier>final</modifier> <modifier>public</modifier> <type>boolean</type><methodname>Thread::start</methodname>
<void/>
<methodparam choice="opt"><type>long</type><parameter>options</parameter></methodparam>
</methodsynopsis>
<para>
Will start a new Thread to execute the implemented run method
@@ -20,7 +20,16 @@
<refsect1 role="parameters">
&reftitle.parameters;
&no.function.parameters;
<variablelist>
<varlistentry>
<term><parameter>options</parameter></term>
<listitem>
<para>
An optional mask of inheritance constants, by default PTHREADS_INHERIT_ALL
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1 role="returnvalues">
@@ -79,4 +88,4 @@ End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->
-->

View File

@@ -5,7 +5,7 @@
-->
<versions>
<!-- Methods -->
<!-- Methods -->
<function name='thread::start' from='PECL pthreads &gt;= 0.34'/>
<function name='thread::run' from='PECL pthreads &gt;= 0.34'/>
<function name='thread::wait' from='PECL pthreads &gt;= 0.34'/>
@@ -15,6 +15,7 @@
<function name='thread::isrunning' from='PECL pthreads &gt;= 0.34'/>
<function name='thread::isjoined' from='PECL pthreads &gt;= 0.34'/>
<function name='thread::iswaiting' from='PECL pthreads &gt;= 0.34'/>
<function name='thread::isterminated' from='PECL pthreads &gt;= 0.43'/>
<function name='thread::getthreadid' from='PECL pthreads &gt;= 0.34'/>
<function name='thread::getcreatorid' from='PECL pthreads &gt;= 0.36'/>
<function name='thread::synchronized' from='PECL pthreads &gt;= 0.40'/>
@@ -35,6 +36,7 @@
<function name='stackable::notify' from='PECL pthreads &gt;= 0.36'/>
<function name='stackable::isrunning' from='PECL pthreads &gt;= 0.36'/>
<function name='stackable::iswaiting' from='PECL pthreads &gt;= 0.36'/>
<function name='stackable::isterminated' from='PECL pthreads &gt;= 0.43'/>
<function name='stackable::synchronized' from='PECL pthreads &gt;= 0.40'/>
<function name='stackable::lock' from='PECL pthreads &gt;= 0.40'/>
<function name='stackable::unlock' from='PECL pthreads &gt;= 0.40'/>
@@ -69,4 +71,4 @@ End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->
-->

View File

@@ -11,7 +11,7 @@
&reftitle.description;
<methodsynopsis>
<modifier>final</modifier> <modifier>public</modifier> <type>boolean</type><methodname>Worker::start</methodname>
<void />
<methodparam choice="opt"><type>long</type><parameter>options</parameter></methodparam>
</methodsynopsis>
<para>
Will start a new Thread, executing Worker::run and then waiting for Stackables
@@ -20,7 +20,16 @@
<refsect1 role="parameters">
&reftitle.parameters;
&no.function.parameters;
<variablelist>
<varlistentry>
<term><parameter>options</parameter></term>
<listitem>
<para>
An optional mask of inheritance constants, by default PTHREADS_INHERIT_ALL
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1 role="returnvalues">
@@ -78,4 +87,4 @@ End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->
-->