1
0
mirror of https://github.com/php/doc-en.git synced 2026-03-23 23:32:18 +01:00

pthreads : fix XML by converting para to simpara tags via script

This commit is contained in:
Gina Peter Banyard
2026-01-19 03:13:47 +00:00
parent 1f35172180
commit bf92d8bd83
43 changed files with 298 additions and 320 deletions

View File

@@ -1,18 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<book xml:id="book.pthreads" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<book xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="book.pthreads">
<?phpdoc extension-membership="pecl" ?>
<title>pthreads</title>
<titleabbrev>pthreads</titleabbrev>
<preface xml:id="intro.pthreads">
&reftitle.intro;
<para>
<simpara>
pthreads is an object-orientated API that provides all of the tools needed
for multi-threading in PHP. PHP applications can create, read, write,
execute and synchronize with Threads, Workers and Threaded objects.
</para>
</simpara>
<warning>
<simpara>
This extension is considered unmaintained and dead.
@@ -24,66 +23,66 @@
</simpara>
</tip>
<warning>
<para>
<simpara>
The pthreads extension cannot be used in a web server environment.
Threading in PHP is therefore restricted to CLI-based applications only.
</para>
</simpara>
</warning>
<warning>
<para>
<simpara>
pthreads (v3) can only be used with PHP 7.2+: This is due to ZTS
mode being unsafe in 7.0 and 7.1.
</para>
</simpara>
</warning>
<para>
<simpara>
The <classname>Threaded</classname> class forms the basis of the
functionality that allows pthreads to operate. It exposes synchronization
methods and some useful interfaces for the programmer.
</para>
<para>
</simpara>
<simpara>
The <classname>Thread</classname> class enables for threads to be created by
simply extending it and implementing a <literal>run</literal> method. Any
members can be written to and read by any context with a reference to the
thread. Any context can also execute any public and protected methods.
thread. Any context can also execute any public and protected methods.
The body of the run method will be executed in a separate thread when the
<methodname>Thread::start</methodname> method of the implementation is
called from the context that created it. Only the context that creates a
thread can start and join it.
</para>
<para>
</simpara>
<simpara>
The <classname>Worker</classname> class has a persistent state, and will be
available from the call to <methodname>Thread::start</methodname> (an
inherited method) until the object goes out of scope, or is explicitly
shutdown (via <methodname>Worker::shutdown</methodname>). Any context with a
reference to the worker object can stack tasks onto the Worker (via
reference to the worker object can stack tasks onto the Worker (via
<methodname>Worker::stack</methodname>), where these tasks will be executed
by the worker in a separate thread. The <literal>run</literal> method of a
worker object will be executed before any objects on the worker's stack,
enabling for resources to be initialized that the objects to be executed may
need.
</para>
<para>
</simpara>
<simpara>
The <classname>Pool</classname> class is used to create a group of workers
to distribute <classname>Threaded</classname> objects amongst them. It is
the easiest and most efficient way of using multiple threads in PHP
applications.
</para>
</simpara>
<caution>
<para>
<simpara>
The <classname>Pool</classname> class does not extend the
<classname>Threaded</classname> class, and so pool-based objects are
considered a normal PHP objects. As such, its instances of it should not be
shared amongst different contexts.
</para>
</simpara>
</caution>
<para>
<simpara>
The <classname>Volatile</classname> class is new to pthreads v3. It is used
to denote mutable <classname>Threaded</classname> properties of
<classname>Threaded</classname> classes (since these are now immutable by
default). It is also used to store PHP arrays in
<classname>Threaded</classname> contexts.
</para>
<para>
</simpara>
<simpara>
Synchronization is an important ability when threading. All of the objects
that pthreads creates have built in synchronization in the (which will be
familiar to java programmers) form of
@@ -94,43 +93,43 @@
<methodname>Threaded::notify</methodname> on the same object. This mechanism
allows for powerful synchronization between <classname>Threaded</classname>
objects in PHP.
</para>
</simpara>
<caution>
<para>
<simpara>
Any objects that are intended for use in the multi-threaded parts of your
application should extend <classname>Threaded</classname>.
</para>
</simpara>
</caution>
<para>
<simpara>
Data Storage:
As a rule of thumb, any data type that can be serialized can be used as a member of a Threaded object, it can be read and written from any context with a reference to the Threaded Object.
Not every type of data is stored serially, basic types are stored in their true form.
As a rule of thumb, any data type that can be serialized can be used as a member of a Threaded object, it can be read and written from any context with a reference to the Threaded Object.
Not every type of data is stored serially, basic types are stored in their true form.
Complex types, Arrays, and Objects that are not Threaded are stored serially; they can be read and written to the Threaded Object from any context with a reference.
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;
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>
</simpara>
<simpara>
Static Members:
When a new context is created ( Thread or Worker ), they are generally copied, but resources and objects with internal state are nullified (for safety reasons). 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>
</simpara>
<caution>
<para>
<simpara>
When print_r, var_dump and other object debug functions are executed, they do not include recursion protection.
</para>
</simpara>
</caution>
<note>
<para>
<simpara>
Resources:
The extensions and functionality that define resources in PHP are completely unprepared for this kind of environment; pthreads makes provisions for Resources to be shared among contexts, however, for most types of resource it should be considered unsafe. Extreme caution and care should be used when sharing resources among contexts.
</para>
</simpara>
</note>
<caution>
<para>
<simpara>
In the environment which pthreads executes, some restrictions and limitations are necessary in order to provide a stable environment.
</para>
</simpara>
</caution>
</preface>
&reference.pthreads.setup;
&reference.pthreads.constants;
&reference.pthreads.threaded;
@@ -141,7 +140,6 @@
&reference.pthreads.volatile;
</book>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml

View File

@@ -1,19 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<reference xml:id="class.collectable" role="class" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude">
<reference xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude" xml:id="class.collectable" role="class">
<title>The Collectable interface</title>
<titleabbrev>Collectable</titleabbrev>
<partintro>
<!-- {{{ Collectable intro -->
<section xml:id="collectable.intro">
&reftitle.intro;
<para>
<simpara>
Represents a garbage-collectable object.
</para>
</simpara>
</section>
<!-- }}} -->
@@ -31,9 +30,9 @@
</oointerface>
</classsynopsisinfo>
<!-- }}} -->
<classsynopsisinfo role="comment">&Methods;</classsynopsisinfo>
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.collectable')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[not(@role='procedural')])" />
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.collectable')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[not(@role='procedural')])"/>
</classsynopsis>
<!-- }}} -->
@@ -45,7 +44,6 @@
&reference.pthreads.entities.collectable;
</reference>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml

View File

@@ -12,9 +12,9 @@
<modifier>public</modifier> <type>true</type><methodname>Collectable::isGarbage</methodname>
<void/>
</methodsynopsis>
<para>
<simpara>
Can be called in <methodname>Pool::collect</methodname> to determine if this object is garbage.
</para>
</simpara>
</refsect1>
<refsect1 role="parameters">
@@ -24,9 +24,9 @@
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
<simpara>
&return.true.always;
</para>
</simpara>
</refsect1>
<refsect1 role="changelog">

View File

@@ -1,27 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<section xml:id="pthreads.installation" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<section xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="pthreads.installation">
&reftitle.install;
<para>
<simpara>
Use <option role="configure">--enable-maintainer-zts</option> when compiling PHP.
</para>
</simpara>
<para>
<simpara>
Windows users should include <filename>php_pthreads.dll</filename> into &php.ini;
</para>
</simpara>
<note>
<para>
<simpara>
Windows users also have to make sure that <filename>pthreadVC2.dll</filename>
(included with the distribution) is present in one of the folders specified
in the <envar>PATH</envar> environment variable.
</para>
</simpara>
</note>
</section>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml

View File

@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<reference xml:id="class.pool" role="class" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude">
<reference xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude" xml:id="class.pool" role="class">
<title>The Pool class</title>
<titleabbrev>Pool</titleabbrev>
@@ -11,12 +10,12 @@
<!-- {{{ Pool intro -->
<section xml:id="pool.intro">
&reftitle.intro;
<para>
<simpara>
A Pool is a container for, and controller of, an adjustable number of Workers.
</para>
<para>
</simpara>
<simpara>
Pooling provides a higher level abstraction of the Worker functionality, including the management of references in the way required by pthreads.
</para>
</simpara>
</section>
<!-- }}} -->
@@ -68,7 +67,7 @@
</section>
<!-- {{{ Pool properties -->
<section xml:id="pool.props">
&reftitle.properties;
@@ -76,31 +75,31 @@
<varlistentry xml:id="pool.props.size">
<term><varname>size</varname></term>
<listitem>
<para>maximum number of Workers this Pool can use</para>
<simpara>maximum number of Workers this Pool can use</simpara>
</listitem>
</varlistentry>
<varlistentry xml:id="pool.props.class">
<term><varname>class</varname></term>
<listitem>
<para>the class of the Worker</para>
<simpara>the class of the Worker</simpara>
</listitem>
</varlistentry>
<varlistentry xml:id="pool.props.workers">
<term><varname>workers</varname></term>
<listitem>
<para>references to Workers</para>
<simpara>references to Workers</simpara>
</listitem>
</varlistentry>
<varlistentry xml:id="pool.props.ctor">
<term><varname>ctor</varname></term>
<listitem>
<para>the arguments for constructor of new Workers</para>
<simpara>the arguments for constructor of new Workers</simpara>
</listitem>
</varlistentry>
<varlistentry xml:id="pool.props.last">
<term><varname>last</varname></term>
<listitem>
<para>offset in workers of the last Worker used</para>
<simpara>offset in workers of the last Worker used</simpara>
</listitem>
</varlistentry>
</variablelist>
@@ -113,7 +112,6 @@
&reference.pthreads.entities.pool;
</reference>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml

View File

@@ -12,10 +12,10 @@
<modifier>public</modifier> <type>int</type><methodname>Pool::collect</methodname>
<methodparam choice="opt"><type>Callable</type><parameter>collector</parameter></methodparam>
</methodsynopsis>
<para>
<simpara>
Allows the pool to collect references determined to be garbage by the
optionally given collector.
</para>
</simpara>
</refsect1>
<refsect1 role="parameters">
@@ -24,11 +24,11 @@
<varlistentry>
<term><parameter>collector</parameter></term>
<listitem>
<para>
<simpara>
A Callable collector that returns a boolean on whether the task can be
collected or not. Only in rare cases should a custom collector need to
be used.
</para>
</simpara>
</listitem>
</varlistentry>
</variablelist>
@@ -36,9 +36,9 @@
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
<simpara>
The number of remaining tasks in the pool to be collected.
</para>
</simpara>
</refsect1>
<refsect1 role="changelog">

View File

@@ -14,11 +14,11 @@
<methodparam choice="opt"><type>string</type><parameter>class</parameter></methodparam>
<methodparam choice="opt"><type>array</type><parameter>ctor</parameter></methodparam>
</constructorsynopsis>
<para>
<simpara>
Construct a new pool of workers. Pools lazily create their threads, which
means new threads will only be spawned when they are required to execute
tasks.
</para>
</simpara>
</refsect1>
<refsect1 role="parameters">
@@ -27,26 +27,26 @@
<varlistentry>
<term><parameter>size</parameter></term>
<listitem>
<para>
<simpara>
The maximum number of workers for this pool to create
</para>
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>class</parameter></term>
<listitem>
<para>
<simpara>
The class for new Workers. If no class is given, then it defaults to the
<classname>Worker</classname> class.
</para>
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>ctor</parameter></term>
<listitem>
<para>
<simpara>
An array of arguments to be passed to new workers' constructors
</para>
</simpara>
</listitem>
</varlistentry>
</variablelist>

View File

@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="pool.resize" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="pool.resize">
<refnamediv>
<refname>Pool::resize</refname>
<refpurpose>Resize the Pool</refpurpose>
@@ -13,9 +12,9 @@
<modifier>public</modifier> <type>void</type><methodname>Pool::resize</methodname>
<methodparam><type>int</type><parameter>size</parameter></methodparam>
</methodsynopsis>
<para>
<simpara>
Resize the Pool
</para>
</simpara>
</refsect1>
<refsect1 role="parameters">
@@ -24,9 +23,9 @@
<varlistentry>
<term><parameter>size</parameter></term>
<listitem>
<para>
<simpara>
The maximum number of Workers this Pool can create
</para>
</simpara>
</listitem>
</varlistentry>
</variablelist>
@@ -34,12 +33,11 @@
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
<simpara>
&return.void;
</para>
</simpara>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml

View File

@@ -12,10 +12,10 @@
<modifier>public</modifier> <type>void</type><methodname>Pool::shutdown</methodname>
<void/>
</methodsynopsis>
<para>
<simpara>
Shuts down all of the workers in the pool. This will block until all
submitted tasks have been executed.
</para>
</simpara>
</refsect1>
<refsect1 role="parameters">
@@ -25,9 +25,9 @@
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
<simpara>
&return.void;
</para>
</simpara>
</refsect1>
<refsect1 role="examples">

View File

@@ -12,9 +12,9 @@
<modifier>public</modifier> <type>int</type><methodname>Pool::submit</methodname>
<methodparam><type>Threaded</type><parameter>task</parameter></methodparam>
</methodsynopsis>
<para>
<simpara>
Submit the task to the next Worker in the Pool
</para>
</simpara>
</refsect1>
<refsect1 role="parameters">
@@ -23,9 +23,9 @@
<varlistentry>
<term><parameter>task</parameter></term>
<listitem>
<para>
<simpara>
The task for execution
</para>
</simpara>
</listitem>
</varlistentry>
</variablelist>
@@ -33,9 +33,9 @@
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
<simpara>
the identifier of the Worker executing the object
</para>
</simpara>
</refsect1>
<refsect1 role="examples">

View File

@@ -13,11 +13,11 @@
<methodparam><type>int</type><parameter>worker</parameter></methodparam>
<methodparam><type>Threaded</type><parameter>task</parameter></methodparam>
</methodsynopsis>
<para>
<simpara>
Submit a task to the specified worker in the pool. The workers are indexed
from 0, and will only exist if the pool has needed to create them (since
threads are lazily spawned).
</para>
</simpara>
</refsect1>
<refsect1 role="parameters">
@@ -26,17 +26,17 @@
<varlistentry>
<term><parameter>worker</parameter></term>
<listitem>
<para>
<simpara>
The worker to stack the task onto, indexed from <literal>0</literal>.
</para>
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>task</parameter></term>
<listitem>
<para>
<simpara>
The task for execution.
</para>
</simpara>
</listitem>
</varlistentry>
</variablelist>
@@ -44,9 +44,9 @@
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
<simpara>
The identifier of the worker that accepted the task.
</para>
</simpara>
</refsect1>
<refsect1 role="examples">

View File

@@ -1,46 +1,44 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<chapter xml:id="pthreads.setup" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<chapter xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="pthreads.setup">
&reftitle.setup;
<section xml:id="pthreads.requirements">
&reftitle.required;
<para>
<simpara>
pthreads requires a build of PHP with ZTS (Zend Thread Safety) enabled
(<option role="configure">--enable-zts</option>, or on non-Windows systems prior to PHP 8.0.0,
<option role="configure">--enable-maintainer-zts</option>)
</para>
</simpara>
<caution>
<para>
<simpara>
Zend Thread Safety cannot be enabled post build; it is a build time configuration option.
</para>
</simpara>
</caution>
<para>
<simpara>
pthreads should build anywhere there is a working Posix Threads header (pthread.h) and ZTS build of PHP, including Windows (using the pthread-w32 project from redhat).
</para>
</simpara>
</section>
<section xml:id="pthreads.installation">
&reftitle.install;
<para>
<simpara>
pthreads releases are hosted by PECL and the source code by
<link xlink:href="&url.git.hub;krakjoe/pthreads">github</link>,
the easiest route to installation is the normal PECL route:
<link xlink:href="&url.pecl.package;pthreads">&url.pecl.package;pthreads</link>.
</para>
<para>
</simpara>
<simpara>
Windows users can download prebuilt release binaries from the <link xlink:href="&url.pecl.package;pthreads">PECL</link> website.
</para>
</simpara>
<caution>
<para>
<simpara>
Windows users need to take the additional step of adding pthreadVC2.dll (distributed with Windows releases) to their <envar>PATH</envar>.
</para>
</simpara>
</caution>
</section>
</chapter>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml

View File

@@ -1,26 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<reference xml:id="class.thread" role="class" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude">
<reference xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude" xml:id="class.thread" role="class">
<title>The Thread class</title>
<titleabbrev>Thread</titleabbrev>
<partintro>
<!-- {{{ Thread intro -->
<section xml:id="thread.intro">
&reftitle.intro;
<para>
<simpara>
When the start method of a Thread is invoked, the run method code will be executed in separate Thread, in parallel.
</para>
<para>
</simpara>
<simpara>
After the run method is executed the Thread will exit immediately, it will be joined with the creating Thread at the appropriate time.
</para>
</simpara>
<warning>
<para>
<simpara>
Relying on the engine to determine when a Thread should join may cause undesirable behaviour; the programmer should be explicit, where possible.
</para>
</simpara>
</warning>
</section>
<!-- }}} -->
@@ -37,12 +36,12 @@
<ooclass>
<classname>Thread</classname>
</ooclass>
<ooclass>
<modifier>extends</modifier>
<classname>Threaded</classname>
</ooclass>
<oointerface>
<interfacename>Countable</interfacename>
</oointerface>
@@ -50,18 +49,18 @@
<oointerface>
<interfacename>Traversable</interfacename>
</oointerface>
<oointerface>
<interfacename>ArrayAccess</interfacename>
</oointerface>
</classsynopsisinfo>
<!-- }}} -->
<classsynopsisinfo role="comment">&Methods;</classsynopsisinfo>
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.thread')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[not(@role='procedural')])" />
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.thread')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[not(@role='procedural')])"/>
<classsynopsisinfo role="comment">&InheritedMethods;</classsynopsisinfo>
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.threaded')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[not(@role='procedural')])" />
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.threaded')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[not(@role='procedural')])"/>
</classsynopsis>
<!-- }}} -->
@@ -73,7 +72,6 @@
&reference.pthreads.entities.thread;
</reference>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml

View File

@@ -12,9 +12,9 @@
<modifier>public</modifier> <type>int</type><methodname>Thread::getCreatorId</methodname>
<void/>
</methodsynopsis>
<para>
<simpara>
Will return the identity of the Thread that created the referenced Thread
</para>
</simpara>
</refsect1>
<refsect1 role="parameters">
@@ -24,9 +24,9 @@
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
<simpara>
A numeric identity
</para>
</simpara>
</refsect1>
<refsect1 role="examples">

View File

@@ -12,9 +12,9 @@
<modifier>public</modifier> <modifier>static</modifier> <type>Thread</type><methodname>Thread::getCurrentThread</methodname>
<void/>
</methodsynopsis>
<para>
<simpara>
Return a reference to the currently executing Thread
</para>
</simpara>
</refsect1>
@@ -25,9 +25,9 @@
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
<simpara>
An object representing the currently executing Thread
</para>
</simpara>
</refsect1>
<refsect1 role="examples">

View File

@@ -12,9 +12,9 @@
<modifier>public</modifier> <modifier>static</modifier> <type>int</type><methodname>Thread::getCurrentThreadId</methodname>
<void/>
</methodsynopsis>
<para>
<simpara>
Will return the identity of the currently executing Thread
</para>
</simpara>
</refsect1>
<refsect1 role="parameters">
@@ -24,9 +24,9 @@
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
<simpara>
A numeric identity
</para>
</simpara>
</refsect1>
<refsect1 role="examples">

View File

@@ -12,9 +12,9 @@
<modifier>public</modifier> <type>int</type><methodname>Thread::getThreadId</methodname>
<void/>
</methodsynopsis>
<para>
<simpara>
Will return the identity of the referenced Thread
</para>
</simpara>
</refsect1>
<refsect1 role="parameters">
@@ -24,9 +24,9 @@
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
<simpara>
A numeric identity
</para>
</simpara>
</refsect1>
<refsect1 role="examples">

View File

@@ -12,9 +12,9 @@
<modifier>public</modifier> <type>bool</type><methodname>Thread::isJoined</methodname>
<void/>
</methodsynopsis>
<para>
<simpara>
Tell if the referenced Thread has been joined
</para>
</simpara>
</refsect1>
<refsect1 role="parameters">
@@ -24,9 +24,9 @@
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
<simpara>
&return.success;
</para>
</simpara>
</refsect1>
<refsect1 role="examples">

View File

@@ -12,9 +12,9 @@
<modifier>public</modifier> <type>bool</type><methodname>Thread::isStarted</methodname>
<void/>
</methodsynopsis>
<para>
<simpara>
Tell if the referenced Thread was started
</para>
</simpara>
</refsect1>
@@ -25,9 +25,9 @@
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
<simpara>
&return.success;
</para>
</simpara>
</refsect1>
<refsect1 role="examples">

View File

@@ -12,9 +12,9 @@
<modifier>public</modifier> <type>bool</type><methodname>Thread::join</methodname>
<void/>
</methodsynopsis>
<para>
<simpara>
Causes the calling context to wait for the referenced Thread to finish executing
</para>
</simpara>
</refsect1>
<refsect1 role="parameters">
@@ -24,9 +24,9 @@
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
<simpara>
&return.success;
</para>
</simpara>
</refsect1>
<refsect1 role="examples">

View File

@@ -12,9 +12,9 @@
<modifier>public</modifier> <type>bool</type><methodname>Thread::start</methodname>
<methodparam choice="opt"><type>int</type><parameter>options</parameter></methodparam>
</methodsynopsis>
<para>
<simpara>
Will start a new Thread to execute the implemented run method
</para>
</simpara>
</refsect1>
<refsect1 role="parameters">
@@ -23,9 +23,9 @@
<varlistentry>
<term><parameter>options</parameter></term>
<listitem>
<para>
<simpara>
An optional mask of inheritance constants, by default PTHREADS_INHERIT_ALL
</para>
</simpara>
</listitem>
</varlistentry>
</variablelist>
@@ -33,9 +33,9 @@
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
<simpara>
&return.success;
</para>
</simpara>
</refsect1>
<refsect1 role="examples">

View File

@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<reference xml:id="class.threaded" role="class" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude">
<reference xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude" xml:id="class.threaded" role="class">
<title>The Threaded class</title>
<titleabbrev>Threaded</titleabbrev>
@@ -11,12 +10,12 @@
<!-- {{{ Threaded intro -->
<section xml:id="threaded.intro">
&reftitle.intro;
<para>
<simpara>
Threaded objects form the basis of pthreads ability to execute user code in parallel; they expose synchronization methods and various useful interfaces.
</para>
<para>
</simpara>
<simpara>
Threaded objects, most importantly, provide implicit safety for the programmer; all operations on the object scope are safe.
</para>
</simpara>
</section>
<!-- }}} -->
@@ -44,15 +43,15 @@
<oointerface>
<interfacename>Countable</interfacename>
</oointerface>
<oointerface>
<interfacename>ArrayAccess</interfacename>
</oointerface>
</classsynopsisinfo>
<!-- }}} -->
<classsynopsisinfo role="comment">&Methods;</classsynopsisinfo>
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.threaded')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[not(@role='procedural')])" />
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.threaded')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[not(@role='procedural')])"/>
</classsynopsis>
<!-- }}} -->
@@ -63,7 +62,6 @@
&reference.pthreads.entities.threaded;
</reference>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml

View File

@@ -13,9 +13,9 @@
<methodparam><type>int</type><parameter>size</parameter></methodparam>
<methodparam><type>bool</type><parameter>preserve</parameter></methodparam>
</methodsynopsis>
<para>
<simpara>
Fetches a chunk of the objects property table of the given size, optionally preserving keys
</para>
</simpara>
</refsect1>
<refsect1 role="parameters">
@@ -24,17 +24,17 @@
<varlistentry>
<term><parameter>size</parameter></term>
<listitem>
<para>
<simpara>
The number of items to fetch
</para>
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>preserve</parameter></term>
<listitem>
<para>
<simpara>
Preserve the keys of members, by default false
</para>
</simpara>
</listitem>
</varlistentry>
</variablelist>
@@ -42,9 +42,9 @@
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
<simpara>
An array of items from the objects property table
</para>
</simpara>
</refsect1>
<refsect1 role="examples">

View File

@@ -12,9 +12,9 @@
<modifier>public</modifier> <type>int</type><methodname>Threaded::count</methodname>
<void/>
</methodsynopsis>
<para>
<simpara>
Returns the number of properties for this object
</para>
</simpara>
</refsect1>
@@ -25,9 +25,9 @@
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
<simpara>
</para>
</simpara>
</refsect1>
<refsect1 role="examples">

View File

@@ -12,9 +12,9 @@
<modifier>public</modifier> <type>bool</type><methodname>Threaded::extend</methodname>
<methodparam><type>string</type><parameter>class</parameter></methodparam>
</methodsynopsis>
<para>
<simpara>
Makes thread safe standard class at runtime
</para>
</simpara>
</refsect1>
<refsect1 role="parameters">
@@ -23,9 +23,9 @@
<varlistentry>
<term><parameter>class</parameter></term>
<listitem>
<para>
<simpara>
The class to extend
</para>
</simpara>
</listitem>
</varlistentry>
</variablelist>
@@ -33,9 +33,9 @@
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
<simpara>
&return.success;
</para>
</simpara>
</refsect1>
<refsect1 role="examples">

View File

@@ -12,9 +12,9 @@
<modifier>public</modifier> <type>bool</type><methodname>Threaded::isRunning</methodname>
<void/>
</methodsynopsis>
<para>
<simpara>
Tell if the referenced object is executing
</para>
</simpara>
</refsect1>
<refsect1 role="parameters">
@@ -27,9 +27,9 @@
<para>
A boolean indication of state
<note>
<para>
<simpara>
A object is considered running while executing the run method
</para>
</simpara>
</note>
</para>
</refsect1>

View File

@@ -12,9 +12,9 @@
<modifier>public</modifier> <type>bool</type><methodname>Threaded::isTerminated</methodname>
<void/>
</methodsynopsis>
<para>
<simpara>
Tell if the referenced object was terminated during execution; suffered fatal errors, or threw uncaught exceptions
</para>
</simpara>
</refsect1>
<refsect1 role="parameters">
@@ -24,9 +24,9 @@
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
<simpara>
A boolean indication of state
</para>
</simpara>
</refsect1>
<refsect1 role="examples">

View File

@@ -13,9 +13,9 @@
<methodparam><type>mixed</type><parameter>from</parameter></methodparam>
<methodparam choice="opt"><type>bool</type><parameter>overwrite</parameter></methodparam>
</methodsynopsis>
<para>
<simpara>
Merges data into the current object
</para>
</simpara>
</refsect1>
<refsect1 role="parameters">
@@ -24,17 +24,17 @@
<varlistentry>
<term><parameter>from</parameter></term>
<listitem>
<para>
<simpara>
The data to merge
</para>
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>overwrite</parameter></term>
<listitem>
<para>
<simpara>
Overwrite existing keys, by default true
</para>
</simpara>
</listitem>
</varlistentry>
</variablelist>
@@ -42,9 +42,9 @@
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
<simpara>
&return.success;
</para>
</simpara>
</refsect1>
<refsect1 role="examples">

View File

@@ -12,9 +12,9 @@
<modifier>public</modifier> <type>bool</type><methodname>Threaded::notify</methodname>
<void/>
</methodsynopsis>
<para>
<simpara>
Send notification to the referenced object
</para>
</simpara>
</refsect1>
<refsect1 role="parameters">
@@ -24,9 +24,9 @@
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
<simpara>
&return.success;
</para>
</simpara>
</refsect1>
<refsect1 role="examples">

View File

@@ -12,11 +12,11 @@
<modifier>public</modifier> <type>bool</type><methodname>Threaded::notifyOne</methodname>
<void/>
</methodsynopsis>
<para>
<simpara>
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>
</simpara>
</refsect1>
<refsect1 role="parameters">
@@ -26,9 +26,9 @@
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
<simpara>
&return.success;
</para>
</simpara>
</refsect1>
<refsect1 role="examples">

View File

@@ -12,9 +12,9 @@
<modifier>public</modifier> <type>bool</type><methodname>Threaded::pop</methodname>
<void/>
</methodsynopsis>
<para>
<simpara>
Pops an item from the objects property table
</para>
</simpara>
</refsect1>
<refsect1 role="parameters">
@@ -24,9 +24,9 @@
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
<simpara>
The last item from the objects property table
</para>
</simpara>
</refsect1>
<refsect1 role="examples">

View File

@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="threaded.run" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="threaded.run">
<refnamediv>
<refname>Threaded::run</refname>
<refpurpose>Execution</refpurpose>
@@ -11,11 +10,11 @@
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <type>void</type><methodname>Threaded::run</methodname>
<void />
<void/>
</methodsynopsis>
<para>
<simpara>
The programmer should always implement the run method for objects that are intended for execution.
</para>
</simpara>
</refsect1>
<refsect1 role="parameters">
@@ -25,14 +24,13 @@
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
<simpara>
The methods return value, if used, will be ignored
</para>
</simpara>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml

View File

@@ -12,9 +12,9 @@
<modifier>public</modifier> <type>mixed</type><methodname>Threaded::shift</methodname>
<void/>
</methodsynopsis>
<para>
<simpara>
Shifts an item from the objects property table
</para>
</simpara>
</refsect1>
<refsect1 role="parameters">
@@ -24,9 +24,9 @@
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
<simpara>
The first item from the objects property table
</para>
</simpara>
</refsect1>
<refsect1 role="examples">

View File

@@ -13,9 +13,9 @@
<methodparam><type>Closure</type><parameter>block</parameter></methodparam>
<methodparam rep="repeat"><type>mixed</type><parameter>args</parameter></methodparam>
</methodsynopsis>
<para>
<simpara>
Executes the block while retaining the referenced objects synchronization lock for the calling context
</para>
</simpara>
</refsect1>
<refsect1 role="parameters">
@@ -24,17 +24,17 @@
<varlistentry>
<term><parameter>block</parameter></term>
<listitem>
<para>
<simpara>
The block of code to execute
</para>
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>args</parameter></term>
<listitem>
<para>
<simpara>
Variable length list of arguments to use as function arguments to the block
</para>
</simpara>
</listitem>
</varlistentry>
</variablelist>
@@ -42,9 +42,9 @@
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
<simpara>
The return value from the block
</para>
</simpara>
</refsect1>
<refsect1 role="examples">

View File

@@ -12,9 +12,9 @@
<modifier>public</modifier> <type>bool</type><methodname>Threaded::wait</methodname>
<methodparam choice="opt"><type>int</type><parameter>timeout</parameter></methodparam>
</methodsynopsis>
<para>
<simpara>
Will cause the calling context to wait for notification from the referenced object
</para>
</simpara>
</refsect1>
<refsect1 role="parameters">
@@ -23,9 +23,9 @@
<varlistentry>
<term><parameter>timeout</parameter></term>
<listitem>
<para>
<simpara>
An optional timeout in microseconds
</para>
</simpara>
</listitem>
</varlistentry>
</variablelist>
@@ -33,9 +33,9 @@
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
<simpara>
&return.success;
</para>
</simpara>
</refsect1>
<refsect1 role="examples">

View File

@@ -1,24 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<reference xml:id="class.volatile" role="class" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude">
<reference xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude" xml:id="class.volatile" role="class">
<title>The Volatile class</title>
<titleabbrev>Volatile</titleabbrev>
<partintro>
<!-- {{{ Volatile intro -->
<section xml:id="volatile.intro">
&reftitle.intro;
<para>
<simpara>
The <classname>Volatile</classname> class is new to pthreads v3. Its
introduction is a consequence of the new immutability semantics of
<classname>Threaded</classname> members of <classname>Threaded</classname>
classes. The <classname>Volatile</classname> class enables for mutability
of its <classname>Threaded</classname> members, and is also used to store
PHP arrays in <classname>Threaded</classname> contexts.
</para>
</simpara>
</section>
<!-- }}} -->
@@ -34,12 +33,12 @@
<ooclass>
<classname>Volatile</classname>
</ooclass>
<ooclass>
<modifier>extends</modifier>
<classname>Threaded</classname>
</ooclass>
<oointerface>
<interfacename>Collectable</interfacename>
</oointerface>
@@ -51,7 +50,7 @@
<classsynopsisinfo role="comment">&InheritedMethods;</classsynopsisinfo>
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.threaded')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[not(@role='procedural')])">
<xi:fallback />
<xi:fallback/>
</xi:include>
</classsynopsis>
<!-- }}} -->
@@ -120,7 +119,6 @@ object(stdClass)#3 (0) {
</partintro>
</reference>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml

View File

@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<reference xml:id="class.worker" role="class" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude">
<reference xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude" xml:id="class.worker" role="class">
<title>The Worker class</title>
<titleabbrev>Worker</titleabbrev>
@@ -11,27 +10,27 @@
<!-- {{{ Worker intro -->
<section xml:id="worker.intro">
&reftitle.intro;
<para>
<simpara>
Worker Threads have a persistent context, as such should be used over Threads in most cases.
</para>
<para>
</simpara>
<simpara>
When a Worker is started, the run method will be executed, but the Thread will not leave until one of the following conditions are met:
</para>
</simpara>
<itemizedlist>
<listitem>
<para>the Worker goes out of scope (no more references remain)</para>
<simpara>the Worker goes out of scope (no more references remain)</simpara>
</listitem>
<listitem>
<para>the programmer calls shutdown</para>
<simpara>the programmer calls shutdown</simpara>
</listitem>
<listitem>
<para>the script dies</para>
<simpara>the script dies</simpara>
</listitem>
</itemizedlist>
<para>
<simpara>
This means the programmer can reuse the context throughout execution; placing objects on the stack of the Worker will cause the Worker to
execute the stacked objects run method.
</para>
</simpara>
</section>
<!-- }}} -->
@@ -47,12 +46,12 @@
<ooclass>
<classname>Worker</classname>
</ooclass>
<ooclass>
<modifier>extends</modifier>
<classname>Thread</classname>
</ooclass>
<oointerface>
<interfacename>Traversable</interfacename>
</oointerface>
@@ -60,18 +59,18 @@
<oointerface>
<interfacename>Countable</interfacename>
</oointerface>
<oointerface>
<interfacename>ArrayAccess</interfacename>
</oointerface>
</classsynopsisinfo>
<!-- }}} -->
<classsynopsisinfo role="comment">&Methods;</classsynopsisinfo>
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.worker')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[not(@role='procedural')])" />
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.worker')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[not(@role='procedural')])"/>
<classsynopsisinfo role="comment">&InheritedMethods;</classsynopsisinfo>
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.thread')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[not(@role='procedural')])" />
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.thread')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[not(@role='procedural')])"/>
</classsynopsis>
<!-- }}} -->
@@ -83,7 +82,6 @@
&reference.pthreads.entities.worker;
</reference>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml

View File

@@ -12,10 +12,10 @@
<modifier>public</modifier> <type>int</type><methodname>Worker::collect</methodname>
<methodparam choice="opt"><type>Callable</type><parameter>collector</parameter></methodparam>
</methodsynopsis>
<para>
<simpara>
Allows the worker to collect references determined to be garbage by the
optionally given collector.
</para>
</simpara>
</refsect1>
<refsect1 role="parameters">
@@ -24,11 +24,11 @@
<varlistentry>
<term><parameter>collector</parameter></term>
<listitem>
<para>
<simpara>
A Callable collector that returns a boolean on whether the task can be
collected or not. Only in rare cases should a custom collector need to
be used.
</para>
</simpara>
</listitem>
</varlistentry>
</variablelist>
@@ -36,9 +36,9 @@
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
<simpara>
The number of remaining tasks on the worker's stack to be collected.
</para>
</simpara>
</refsect1>
<refsect1 role="examples">

View File

@@ -12,9 +12,9 @@
<modifier>public</modifier> <type>int</type><methodname>Worker::getStacked</methodname>
<void/>
</methodsynopsis>
<para>
<simpara>
Returns the number of tasks left on the stack
</para>
</simpara>
</refsect1>
<refsect1 role="parameters">
@@ -24,9 +24,9 @@
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
<simpara>
Returns the number of tasks currently waiting to be executed by the worker
</para>
</simpara>
</refsect1>
<refsect1 role="examples">

View File

@@ -12,9 +12,9 @@
<modifier>public</modifier> <type>bool</type><methodname>Worker::isShutdown</methodname>
<void/>
</methodsynopsis>
<para>
<simpara>
Whether the worker has been shutdown or not.
</para>
</simpara>
</refsect1>
<refsect1 role="parameters">
@@ -24,9 +24,9 @@
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
<simpara>
Returns whether the worker has been shutdown or not.
</para>
</simpara>
</refsect1>
<refsect1 role="examples">

View File

@@ -12,9 +12,9 @@
<modifier>public</modifier> <type>bool</type><methodname>Worker::shutdown</methodname>
<void/>
</methodsynopsis>
<para>
<simpara>
Shuts down the worker after executing all of the stacked tasks.
</para>
</simpara>
</refsect1>
<refsect1 role="parameters">
@@ -24,9 +24,9 @@
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
<simpara>
&return.success;
</para>
</simpara>
</refsect1>
<refsect1 role="examples">

View File

@@ -12,9 +12,9 @@
<modifier>public</modifier> <type>int</type><methodname>Worker::stack</methodname>
<methodparam><type>Threaded</type><parameter role="reference">work</parameter></methodparam>
</methodsynopsis>
<para>
<simpara>
Appends the new work to the stack of the referenced worker.
</para>
</simpara>
</refsect1>
<refsect1 role="parameters">
@@ -23,9 +23,9 @@
<varlistentry>
<term><parameter>work</parameter></term>
<listitem>
<para>
<simpara>
A <classname>Threaded</classname> object to be executed by the worker.
</para>
</simpara>
</listitem>
</varlistentry>
</variablelist>
@@ -33,9 +33,9 @@
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
<simpara>
The new size of the stack.
</para>
</simpara>
</refsect1>
<refsect1 role="examples">

View File

@@ -12,9 +12,9 @@
<modifier>public</modifier> <type>int</type><methodname>Worker::unstack</methodname>
<void/>
</methodsynopsis>
<para>
<simpara>
Removes the first task (the oldest one) in the stack.
</para>
</simpara>
</refsect1>
<refsect1 role="parameters">
@@ -24,9 +24,9 @@
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
<simpara>
The new size of the stack.
</para>
</simpara>
</refsect1>
<refsect1 role="changelog">