update pthreads documentation for v2

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@332961 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Joe Watkins 2014-03-11 23:24:03 +00:00
parent 36c5526571
commit 6909677c12
43 changed files with 1560 additions and 488 deletions

View file

@ -10,11 +10,15 @@
<para>
pthreads is an Object Orientated API that allows user-land multi-threading in PHP.
It includes all the tools you need to create multi-threaded applications targeted at the Web or the Console.
PHP applications can create, read, write, execute and synchronize with Threads, Workers and Stackables.
PHP applications can create, read, write, execute and synchronize with Threads, Workers and Threaded objects.
</para>
<para>
A Thread Object:
The user can implement a thread by extending the Thread declaration provided by pthreads.
A Threaded Object:
A Threaded Object forms the basis of the functionality that allows pthreads to operate. It exposes synchronization methods and some useful interfaces for the programmer.
</para>
<para>
A Thread:
The user can implement a Thread by extending the Thread declaration provided by pthreads implementing the run method.
Any members can be written and read by any context with a reference to the Thread, any context can also execute any public and protected methods.
The run method of the implementation is executed in a separate thread when the start method of the implementation is called from the context ( that's Thread or Process ) that created it.
Only the context that creates a thread can start and join with it.
@ -22,17 +26,12 @@
<para>
A Worker Object:
A Worker Thread has a persistent state, and will be available from the call to start until the object goes out of scope, or is explicitly shutdown.
Any context with a reference can pass objects of type Stackable to the Worker which will be executed by the Worker in a separate Thread.
The run method of a Worker is executed before any objects on the stack, such that it can initialize resources that the Stackables to come may need.
</para>
<para>
A Stackable Object:
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 its methods before during and after execution.
Any context with a reference can stack objects onto the Worker, which will be executed by the Worker in a separate Thread.
The run method of a Worker is executed before any objects on the stack, such that it can initialize resources that the objects to come may need.
</para>
<para>
A Pool:
A Pool of Worker threads can be used to distribute Stackables among programmer declared Worker classes. The Pool class included implements this functionality and takes care of referencing in a sane manner.
A Pool of Worker threads can be used to distribute Threaded objects among Workers. The Pool class included implements this functionality and takes care of referencing in a sane manner.
Introduced in v1.0.0, the Pool implementation is the easiest and most efficient way of using multiple threads.
</para>
<caution>
@ -46,13 +45,11 @@
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>
<caution>
<para>
Wait, Threaded Objects ?
A Stackable, Thread or Worker can be thought of, and should be used as a Threaded stdClass: A Thread, Worker and Stackable all behave in the same way in any context with a reference.
Any objects that are intended for use in the multi-threaded parts of your application should extend the Stackable, Thread or Worker declaration.
Which means they must implement run but may not ever be executed; it will often be the case that Objects being used in a multi-threaded environment are intended for execution.
Doing so means any context ( that's Thread/Worker/Stackable/Process ) with a reference can read, write and execute the members of the Threaded Object before, during, and after execution.
</para>
Any objects that are intended for use in the multi-threaded parts of your application should extend Threaded.
</para>
</caution>
<para>
Method Modifiers:
The protected methods of Threaded Objects are protected by pthreads, such that only one context may call that method at a time.
@ -87,12 +84,12 @@
</para>
</caution>
</preface>
&reference.pthreads.setup;
&reference.pthreads.constants;
&reference.pthreads.threaded;
&reference.pthreads.thread;
&reference.pthreads.worker;
&reference.pthreads.stackable;
&reference.pthreads.modifiers;
&reference.pthreads.pool;
&reference.pthreads.mutex;

View file

@ -3,7 +3,7 @@
<phpdoc:classref xml:id="class.cond" xmlns:phpdoc="http://php.net/ns/phpdoc" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude">
<title>The Cond class</title>
<title>Condition Variable</title>
<titleabbrev>Cond</titleabbrev>
<partintro>
@ -33,7 +33,7 @@
<!-- }}} -->
<classsynopsisinfo role="comment">&Methods;</classsynopsisinfo>
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.cond')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[1])" />
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.cond')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[not(@role='procedural')])" />
</classsynopsis>
<!-- }}} -->

View file

@ -5,11 +5,19 @@
&reftitle.install;
<para>
&pecl.info;
<link xlink:href="&url.pecl.package;pthreads">&url.pecl.package;pthreads</link>
Use <option role="configure">--enable-maintainer-zts</option> when compiling PHP.
</para>
<para>
Windows users should include <filename>php_pthreads.dll</filename> into &php.ini;
</para>
<note>
<para>
Windows users also require <filename>pthreadVC2.dll</filename> in PATH (included with the distribution)
</para>
</note>
</section>

View file

@ -1,89 +1,112 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<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:
<variablelist>
<varlistentry xml:id="constant.pthreads-inherit-all">
<term>
<constant>PTHREADS_INHERIT_ALL</constant>
(<type>integer</type>)
</term>
<listitem>
<simpara>
The default options for all Threads, causes pthreads to copy the environment when new Threads are started
</simpara>
</listitem>
</varlistentry>
<varlistentry xml:id="constant.pthreads-inherit-none">
<term>
<constant>PTHREADS_INHERIT_NONE</constant>
(<type>integer</type>)
</term>
<listitem>
<simpara>
Do not inherit anything when new Threads are started
</simpara>
</listitem>
</varlistentry>
<varlistentry xml:id="constant.pthreads-inherit-ini">
<term>
<constant>PTHREADS_INHERIT_INI</constant>
(<type>integer</type>)
</term>
<listitem>
<simpara>
Inherit INI entries when new Threads are started
</simpara>
</listitem>
</varlistentry>
<varlistentry xml:id="constant.pthreads-inherit-constants">
<term>
<constant>PTHREADS_INHERIT_CONSTANTS</constant>
(<type>integer</type>)
</term>
<listitem>
<simpara>
Inherit user declared constants when new Threads are started
</simpara>
</listitem>
</varlistentry>
<varlistentry xml:id="constant.pthreads-inherit-classes">
<term>
<constant>PTHREADS_INHERIT_CLASSES</constant>
(<type>integer</type>)
</term>
<listitem>
<simpara>
Inherit user declared classes when new Threads are started
</simpara>
</listitem>
</varlistentry>
<varlistentry xml:id="constant.pthreads-inherit-functions">
<term>
<constant>PTHREADS_INHERIT_FUNCTIONS</constant>
(<type>integer</type>)
</term>
<listitem>
<simpara>
Inherit user declared functions when new Threads are started
</simpara>
</listitem>
</varlistentry>
<varlistentry xml:id="constant.pthreads-inherit-includes">
<term>
<constant>PTHREADS_INHERIT_INCLUDES</constant>
(<type>integer</type>)
</term>
<listitem>
<simpara>
Inherit included file information when new Threads are started
</simpara>
</listitem>
</varlistentry>
<varlistentry xml:id="constant.pthreads-inherit-comments">
<term>
<constant>PTHREADS_INHERIT_COMMENTS</constant>
(<type>integer</type>)
</term>
<listitem>
<simpara>
Inherit all comments when new Threads are started
</simpara>
</listitem>
</varlistentry>
<varlistentry xml:id="constant.pthreads-allow-headers">
<term>
<constant>PTHREADS_ALLOW_HEADERS</constant>
(<type>integer</type>)
</term>
<listitem>
<simpara>
Allow new Threads to send headers to standard output (normally prohibited)
</simpara>
</listitem>
</varlistentry>
</variablelist>
</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_none">
<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

View file

@ -3,7 +3,7 @@
<phpdoc:classref xml:id="class.mutex" xmlns:phpdoc="http://php.net/ns/phpdoc" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude">
<title>The Mutex class</title>
<title>Mutual Exclusion</title>
<titleabbrev>Mutex</titleabbrev>
<partintro>
@ -12,7 +12,7 @@
<section xml:id="mutex.intro">
&reftitle.intro;
<para>
The static methods contained in the Mutex class provide direct access to Posix Mutex functionality.
The static methods contained in the Mutex class provide direct access to Posix Mutex functionality.
</para>
</section>
<!-- }}} -->
@ -33,7 +33,7 @@
<!-- }}} -->
<classsynopsisinfo role="comment">&Methods;</classsynopsisinfo>
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.mutex')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[1])" />
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.mutex')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[not(@role='procedural')])" />
</classsynopsis>
<!-- }}} -->

View file

@ -1,124 +1,123 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<phpdoc:classref xml:id="class.pool"
xmlns:phpdoc="http://php.net/ns/phpdoc"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns="http://docbook.org/ns/docbook">
<title>The Pool class</title>
<titleabbrev>Pool</titleabbrev>
<partintro>
<!-- {{{ Pool intro -->
<section xml:id="pool.intro">
&reftitle.intro;
<para>
A Pool is a container for, and controller of, a number of Worker threads, the number of threads can be adjusted during execution, additionally the Pool provides an easy mechanism to maintain and collect references in the proper way.
</para>
</section>
<!-- }}} -->
<section xml:id="pool.synopsis">
&reftitle.classsynopsis;
<!-- {{{ Synopsis -->
<classsynopsis>
<ooclass><classname>Pool</classname></ooclass>
<!-- {{{ Pool synopsis -->
<classsynopsisinfo>
<ooclass>
<classname>Pool</classname>
</ooclass>
</classsynopsisinfo>
<!-- }}} -->
<classsynopsisinfo role="comment">Properties</classsynopsisinfo>
<fieldsynopsis>
<modifier>protected</modifier>
<type>integer</type>
<varname linkend="pool.props.size">size</varname>
</fieldsynopsis>
<fieldsynopsis>
<modifier>protected</modifier>
<type>array</type>
<varname linkend="pool.props.workers">workers</varname>
</fieldsynopsis>
<fieldsynopsis>
<modifier>protected</modifier>
<type>array</type>
<varname linkend="pool.props.work">work</varname>
</fieldsynopsis>
<fieldsynopsis>
<modifier>protected</modifier>
<type>integer</type>
<varname linkend="pool.props.last">last</varname>
</fieldsynopsis>
<fieldsynopsis>
<modifier>protected</modifier>
<type>string</type>
<varname linkend="pool.props.class">class</varname>
</fieldsynopsis>
<fieldsynopsis>
<modifier>protected</modifier>
<type>array</type>
<varname linkend="pool.props.size">ctor</varname>
</fieldsynopsis>
<classsynopsisinfo role="comment">&Methods;</classsynopsisinfo>
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.pool')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[1])" />
</classsynopsis>
<phpdoc:classref xml:id="class.pool" xmlns:phpdoc="http://php.net/ns/phpdoc" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude">
<title>Pooling</title>
<titleabbrev>Pool</titleabbrev>
<partintro>
<!-- {{{ Pool intro -->
<section xml:id="pool.intro">
&reftitle.intro;
<para>
A Pool is a container for, and controller of, an adjustable number of Workers.
</para>
<para>
Pooling provides a higher level abstraction of the Worker functionality, including the management of references in the way required by pthreads.
</para>
</section>
<!-- }}} -->
<section xml:id="pool.synopsis">
&reftitle.classsynopsis;
<!-- {{{ Synopsis -->
<classsynopsis>
<ooclass><classname>Pool</classname></ooclass>
<!-- {{{ Class synopsis -->
<classsynopsisinfo>
<ooclass>
<classname>Pool</classname>
</ooclass>
</classsynopsisinfo>
<!-- }}} -->
<classsynopsisinfo role="comment">&Properties;</classsynopsisinfo>
<fieldsynopsis>
<modifier>protected</modifier>
<varname linkend="pool.props.size">size</varname>
</fieldsynopsis>
<fieldsynopsis>
<modifier>protected</modifier>
<varname linkend="pool.props.class">class</varname>
</fieldsynopsis>
<fieldsynopsis>
<modifier>protected</modifier>
<varname linkend="pool.props.workers">workers</varname>
</fieldsynopsis>
<fieldsynopsis>
<modifier>protected</modifier>
<varname linkend="pool.props.work">work</varname>
</fieldsynopsis>
<fieldsynopsis>
<modifier>protected</modifier>
<varname linkend="pool.props.ctor">ctor</varname>
</fieldsynopsis>
<fieldsynopsis>
<modifier>protected</modifier>
<varname linkend="pool.props.last">last</varname>
</fieldsynopsis>
<classsynopsisinfo role="comment">&Methods;</classsynopsisinfo>
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.pool')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[not(@role='procedural')])" />
</classsynopsis>
<!-- }}} -->
</section>
<!-- {{{ Pool properties -->
<section xml:id="pool.props">
&reftitle.properties;
<variablelist>
<varlistentry xml:id="pool.props.size">
<term><varname>size</varname></term>
<listitem>
<para>The maximum number of Worker threads allowed in this Pool</para>
<para>maximum number of Workers this Pool can use</para>
</listitem>
</varlistentry>
<varlistentry xml:id="pool.props.class">
<term><varname>class</varname></term>
<listitem>
<para>the class of the Worker</para>
</listitem>
</varlistentry>
<varlistentry xml:id="pool.props.ctor">
<term><varname>ctor</varname></term>
<listitem>
<para>the arguments for constructor of new Workers</para>
</listitem>
</varlistentry>
<varlistentry xml:id="pool.props.workers">
<term><varname>workers</varname></term>
<listitem>
<para>The array of Worker threads for this Pool</para>
<para>references to Workers</para>
</listitem>
</varlistentry>
<varlistentry xml:id="pool.props.work">
<term><varname>work</varname></term>
<listitem>
<para>The array of Stackables submitted to this Pool for execution</para>
<para>references to Threaded objects submitted to the Pool</para>
</listitem>
</varlistentry>
<varlistentry xml:id="pool.props.last">
<term><varname>last</varname></term>
<listitem>
<para>The numeric identifier for the last Worker used by this Pool</para>
</listitem>
</varlistentry>
<varlistentry xml:id="pool.props.class">
<term><varname>workers</varname></term>
<listitem>
<para>The name of the Worker class for this Pool</para>
</listitem>
</varlistentry>
<varlistentry xml:id="pool.props.ctor">
<term><varname>workers</varname></term>
<listitem>
<para>The constructor arguments to be passed by this Pool to new Workers upon construction</para>
<para>offset in workers of the last Worker used</para>
</listitem>
</varlistentry>
</variablelist>
</section>
<!-- }}} -->
</partintro>
&reference.pthreads.entities.pool;
<!-- }}} -->
</partintro>
&reference.pthreads.entities.pool;
</phpdoc:classref>
<!-- Keep this comment at the end of the file
@ -141,4 +140,3 @@ vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->

View file

@ -3,30 +3,31 @@
<chapter xml:id="pthreads.setup" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
&reftitle.setup;
<section xml:id="pthreads.requirements">
&reftitle.required;
<para>
pthreads requires a build of PHP with ZTS enabled ( --enable-maintainer-zts or --enable-zts on Windows )
pthreads requires a build of PHP with ZTS enabled ( --enable-maintainer-zts or --enable-zts on Windows )
</para>
</section>
<!-- {{{ Installation -->
&reference.pthreads.configure;
<!-- }}} -->
<section xml:id="pthreads.installation">
&reftitle.install;
&no.install;
</section>
<section xml:id="pthreads.configuration">
&reftitle.runtime;
&no.config;
</section>
<section xml:id="pthreads.resources">
&reftitle.resources;
<para>
</para>
</section>
</chapter>
<!-- Keep this comment at the end of the file

View file

@ -1,67 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<phpdoc:classref xml:id="class.stackable" xmlns:phpdoc="http://php.net/ns/phpdoc" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude">
<title>The Stackable class</title>
<titleabbrev>Stackable</titleabbrev>
<partintro>
<!-- {{{ Stackable intro -->
<section xml:id="stackable.intro">
&reftitle.intro;
<para>
Stackables are tasks that are executed by Worker threads. You can synchronize with, read, and write Stackable objects before, after and during their execution.
</para>
</section>
<!-- }}} -->
<section xml:id="stackable.synopsis">
&reftitle.classsynopsis;
<!-- {{{ Synopsis -->
<classsynopsis>
<ooclass><classname>Stackable</classname></ooclass>
<!-- {{{ Class synopsis -->
<classsynopsisinfo>
<ooclass>
<classname>Stackable</classname>
</ooclass>
</classsynopsisinfo>
<!-- }}} -->
<classsynopsisinfo role="comment">&Methods;</classsynopsisinfo>
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.stackable')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[1])" />
</classsynopsis>
<!-- }}} -->
</section>
</partintro>
&reference.pthreads.entities.stackable;
</phpdoc:classref>
<!-- 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

@ -3,17 +3,25 @@
<phpdoc:classref xml:id="class.thread" xmlns:phpdoc="http://php.net/ns/phpdoc" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude">
<title>The Thread class</title>
<title>Threads</title>
<titleabbrev>Thread</titleabbrev>
<partintro>
<!-- {{{ Thread intro -->
<section xml:id="thread.intro">
&reftitle.intro;
<para>
An implementation of a Thread should extend this declaration, implementing the run method. When the start method of that object is called, the run method code will be executed in separate Thread.
When the start method of a Thread is invoked, the run method code will be executed in separate Thread, asynchronously.
</para>
<para>
After the run method is executed the Thread will exit immediately, it will be joined with the creating Thread at the approriate time.
</para>
<warning>
<para>
Relying on the engine to determine when a Thread should join may cause undesirable behaviour; the programmer should be explicit, where possible.
</para>
</warning>
</section>
<!-- }}} -->
@ -29,11 +37,32 @@
<ooclass>
<classname>Thread</classname>
</ooclass>
<ooclass>
<modifier>extends</modifier>
<classname>Threaded</classname>
</ooclass>
<oointerface>
<interfacename>Countable</interfacename>
</oointerface>
<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[1])" />
<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')])" />
</classsynopsis>
<!-- }}} -->

View file

@ -0,0 +1,61 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="thread.detach" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>Thread::detach</refname>
<refpurpose>Execution</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <type>void</type><methodname>Thread::detach</methodname>
<void />
</methodsynopsis>
<para>
Detaches the referenced Thread from the calling context, dangerously!
</para>
<warning>
<para>
This method can cause undefined, unsafe behaviour.
It should not usually be used, it is present for completeness and advanced use cases.
</para>
</warning>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
&no.function.parameters;
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
</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

@ -10,7 +10,7 @@
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>final</modifier> <modifier>public</modifier> <type>long</type><methodname>Thread::getCreatorId</methodname>
<modifier>public</modifier> <type>integer</type><methodname>Thread::getCreatorId</methodname>
<void/>
</methodsynopsis>
<para>

View file

@ -0,0 +1,85 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="thread.getcurrentthread" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>Thread::getCurrentThread</refname>
<refpurpose>Identification</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <modifier>static</modifier> <type>Thread</type><methodname>Thread::getCurrentThread</methodname>
<void />
</methodsynopsis>
<para>
Return a reference to the currently executing Thread
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
&no.function.parameters;
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Return the currently executing Thread</title>
<programlisting role="php">
<![CDATA[
<?php
class My extends Thread {
public function run() {
var_dump(Thread::getCurrentThread());
}
}
$my = new My();
$my->start();
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
object(My)#2 (0) {
}
]]>
</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

@ -10,11 +10,11 @@
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>final</modifier> <modifier>public</modifier> <modifier>static</modifier> <type>long</type><methodname>Thread::getCurrentThreadId</methodname>
<modifier>public</modifier> <modifier>static</modifier> <type>integer</type><methodname>Thread::getCurrentThreadId</methodname>
<void />
</methodsynopsis>
<para>
Will return the identity of the currently executing thread
Will return the identity of the currently executing Thread
</para>
</refsect1>

View file

@ -10,7 +10,7 @@
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>final</modifier> <modifier>public</modifier> <type>long</type><methodname>Thread::getThreadId</methodname>
<modifier>public</modifier> <type>integer</type><methodname>Thread::getThreadId</methodname>
<void />
</methodsynopsis>
<para>

View file

@ -10,11 +10,11 @@
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>final</modifier> <modifier>public</modifier> <type>boolean</type><methodname>Thread::isJoined</methodname>
<modifier>public</modifier> <type>boolean</type><methodname>Thread::isJoined</methodname>
<void />
</methodsynopsis>
<para>
Tell if the referenced Thread has been joined by another context
Tell if the referenced Thread has been joined
</para>
</refsect1>
@ -41,7 +41,8 @@
class My extends Thread {
public function run() {
$this->synchronized(function($thread){
$thread->wait();
if (!$thread->done)
$thread->wait();
}, $this);
}
}
@ -49,6 +50,7 @@ $my = new My();
$my->start();
var_dump($my->isJoined());
$my->synchronized(function($thread){
$thread->done = true;
$thread->notify();
}, $my);
?>

View file

@ -10,12 +10,13 @@
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>final</modifier> <modifier>public</modifier> <type>boolean</type><methodname>Thread::isStarted</methodname>
<modifier>public</modifier> <type>boolean</type><methodname>Thread::isStarted</methodname>
<void />
</methodsynopsis>
<para>
Tell if the referenced Thread has been started
Tell if the referenced Thread was started
</para>
</refsect1>
<refsect1 role="parameters">
@ -26,40 +27,10 @@
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
A boolean indication of state
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() {
/* ... */
}
}
$my = new My();
$my->start();
var_dump($my->isStarted());
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
bool(true)
]]>
</screen>
</example>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file

View file

@ -10,7 +10,7 @@
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>final</modifier> <modifier>public</modifier> <type>boolean</type><methodname>Thread::join</methodname>
<modifier>public</modifier> <type>boolean</type><methodname>Thread::join</methodname>
<void />
</methodsynopsis>
<para>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision: 332046 $ -->
<!-- $Revision$ -->
<refentry xml:id="thread.kill" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
@ -10,20 +10,66 @@
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>final</modifier> <modifier>public</modifier> <type>void</type><methodname>Thread::kill</methodname>
<modifier>public</modifier> <type>void</type><methodname>Thread::kill</methodname>
<void />
</methodsynopsis>
<para>
Kills the referenced thread, dangerously !
Forces the referenced Thread to terminate
</para>
<warning>
<para>
The programmer should not ordinarily kill Threads by force
</para>
</warning>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
&no.function.parameters;
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
void
A boolean indication of success
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Kill the referenced Thread</title>
<programlisting role="php">
<![CDATA[
<?php
class T extends Thread {
public function run() {
$stdin = fopen("php://stdin", "r");
while(($line = fgets($stdin))) {
echo $line;
}
}
}
$t = new T();
$t->start();
var_dump($t->kill());
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
bool(true)
]]>
</screen>
</example>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file

View file

@ -10,8 +10,8 @@
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>final</modifier> <modifier>public</modifier> <type>boolean</type><methodname>Thread::start</methodname>
<methodparam choice="opt"><type>long</type><parameter>options</parameter></methodparam>
<modifier>public</modifier> <type>boolean</type><methodname>Thread::start</methodname>
<methodparam choice="opt"><type>integer</type><parameter>options</parameter></methodparam>
</methodsynopsis>
<para>
Will start a new Thread to execute the implemented run method
@ -88,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

@ -0,0 +1,82 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<phpdoc:classref xml:id="class.threaded" xmlns:phpdoc="http://php.net/ns/phpdoc" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude">
<title>Thread Safe Objects</title>
<titleabbrev>Threaded</titleabbrev>
<partintro>
<!-- {{{ Threaded intro -->
<section xml:id="threaded.intro">
&reftitle.intro;
<para>
Threaded objects form the basis of pthreads ability to execute user code asynchronously; they expose and include synchronization methods and various useful interfaces.
</para>
<para>
Threaded objects, most importantly, provide implicit safety for the programmer; all operations on the object scope are safe.
</para>
</section>
<!-- }}} -->
<section xml:id="threaded.synopsis">
&reftitle.classsynopsis;
<!-- {{{ Synopsis -->
<classsynopsis>
<ooclass><classname>Threaded</classname></ooclass>
<!-- {{{ Class synopsis -->
<classsynopsisinfo>
<ooclass>
<classname>Threaded</classname>
</ooclass>
<oointerface>
<interfacename>Traversable</interfacename>
</oointerface>
<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')])" />
</classsynopsis>
<!-- }}} -->
</section>
</partintro>
&reference.pthreads.entities.threaded;
</phpdoc:classref>
<!-- 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,71 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision: 332045 $ -->
<refentry xml:id="threaded.chunk" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>Thread::chunk</refname>
<refpurpose>Manipulation</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier><type>array</type><methodname>Threaded::chunk</methodname>
<methodparam><type>integer</type><parameter>size</parameter></methodparam>
<methodparam><type>boolean</type><parameter>preserve</parameter></methodparam>
</methodsynopsis>
<para>
Fetches a chunk of the objects properties table of the given size, optionally preserving keys
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<variablelist>
<varlistentry>
<term><parameter>size</parameter></term>
<listitem>
<para>
The number of items to fetch
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>preserve</parameter></term>
<listitem>
<para>
Preserve the keys of members, by default false
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
An array of items from the objects property table
</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,56 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="threaded.count" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>Threaded::count</refname>
<refpurpose>Manipulation</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <type>integer</type><methodname>Threaded::count</methodname>
<void />
</methodsynopsis>
<para>
Returns the number of properties for this object
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
&no.function.parameters;
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
</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,56 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="threaded.getterminationinfo" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>Threaded::getTerminationInfo</refname>
<refpurpose>Error Detection</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <type>array</type><methodname>Threaded::getTerminationInfo</methodname>
<void />
</methodsynopsis>
<para>
Retrieves terminal error information from the referenced object
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
&no.function.parameters;
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
</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

@ -1,20 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- $Revision: 328967 $ -->
<refentry xml:id="thread.iswaiting" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refentry xml:id="thread.isrunning" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>Thread::isWaiting</refname>
<refname>Thread::isRunning</refname>
<refpurpose>State Detection</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>final</modifier> <modifier>public</modifier> <type>boolean</type><methodname>Thread::isWaiting</methodname>
<modifier>public</modifier> <type>boolean</type><methodname>Threaded::isRunning</methodname>
<void />
</methodsynopsis>
<para>
Tell if the referenced Thread is waiting for notification
Tell if the referenced object is executing
</para>
</refsect1>
@ -27,6 +27,11 @@
&reftitle.returnvalues;
<para>
A boolean indication of state
<note>
<para>
A object is considered running while executing the run method
</para>
</note>
</para>
</refsect1>
@ -34,21 +39,23 @@
&reftitle.examples;
<para>
<example>
<title>Detect the state of the referenced Thread</title>
<title>Detect the state of the referenced object</title>
<programlisting role="php">
<![CDATA[
<?php
class My extends Thread {
public function run() {
$this->synchronized(function($thread){
$thread->wait();
if (!$thread->done)
$thread->wait();
}, $this);
}
}
$my = new My();
$my->start();
var_dump($my->isRunning());
$my->synchronized(function($thread){
var_dump($thread->isWaiting());
$thread->done = true;
$thread->notify();
}, $my);
?>

View file

@ -1,20 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- $Revision: 329978 $ -->
<refentry xml:id="thread.isterminated" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refentry xml:id="threaded.isterminated" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>Thread::isTerminated</refname>
<refname>Threaded::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>
<modifier>public</modifier> <type>boolean</type><methodname>Threaded::isTerminated</methodname>
<void />
</methodsynopsis>
<para>
Tell if the referenced Thread exited, suffered fatal errors, or threw uncaught exceptions during execution
Tell if the referenced object was terminated during execution; suffered fatal errors, or threw uncaught exceptions
</para>
</refsect1>
@ -34,7 +34,7 @@
&reftitle.examples;
<para>
<example>
<title>Detect the state of the referenced Thread</title>
<title>Detect the state of the referenced object</title>
<programlisting role="php">
<![CDATA[
<?php
@ -80,4 +80,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,92 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision: 328967 $ -->
<refentry xml:id="threaded.iswaiting" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>Threaded::isWaiting</refname>
<refpurpose>State Detection</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <type>boolean</type><methodname>Threaded::isWaiting</methodname>
<void />
</methodsynopsis>
<para>
Tell if the referenced object is waiting for notification
</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 object</title>
<programlisting role="php">
<![CDATA[
<?php
class My extends Thread {
public function run() {
$this->synchronized(function($thread){
if (!$this->done)
$thread->wait();
}, $this);
}
protected $done;
}
$my = new My();
$my->start();
$my->synchronized(function($thread){
var_dump(
$thread->isWaiting());
$thread->done = true;
$thread->notify();
}, $my);
?>
]]>
</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

@ -1,20 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- $Revision: 328988 $ -->
<refentry xml:id="thread.lock" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refentry xml:id="threaded.lock" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>Thread::lock</refname>
<refname>Threaded::lock</refname>
<refpurpose>Synchronization</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>final</modifier> <modifier>public</modifier> <type>boolean</type><methodname>Thread::lock</methodname>
<modifier>public</modifier> <type>boolean</type><methodname>Threaded::lock</methodname>
<void />
</methodsynopsis>
<para>
Lock the referenced objects storage for the calling context
Lock the referenced objects property table
</para>
</refsect1>
@ -34,7 +34,7 @@
&reftitle.examples;
<para>
<example>
<title>Locking Thread Storage</title>
<title>Locking Object Properties</title>
<programlisting role="php">
<![CDATA[
<?php

View file

@ -0,0 +1,71 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision: 331306 $ -->
<refentry xml:id="threaded.merge" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>Threaded::merge</refname>
<refpurpose>Manipulation</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <type>boolean</type><methodname>Threaded::merge</methodname>
<methodparam><type>mixed</type><parameter>from</parameter></methodparam>
<methodparam choice="opt"><type>mixed</type><parameter>overwrite</parameter></methodparam>
</methodsynopsis>
<para>
Merges data into the current object
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<variablelist>
<varlistentry>
<term><parameter>from</parameter></term>
<listitem>
<para>
The data to merge
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>overwrite</parameter></term>
<listitem>
<para>
Overwrite existing keys flag, by default true
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
A boolean indication of success
</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,91 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision: 328967 $ -->
<refentry xml:id="threaded.notify" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>Threaded::notify</refname>
<refpurpose>Synchronization</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <type>boolean</type><methodname>Threaded::notify</methodname>
<void />
</methodsynopsis>
<para>
Send notification to the referenced object
</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->notify();
}, $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

@ -0,0 +1,48 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision: 332046 $ -->
<refentry xml:id="threaded.pop" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>Threaded::pop</refname>
<refpurpose>Manipulation</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <type>boolean</type><methodname>Threaded::pop</methodname>
<void />
</methodsynopsis>
<para>
Pops an item from the objects property table
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
The last item from the objects property table
</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,55 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision: 328274 $ -->
<refentry xml:id="threaded.run" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>Threaded::run</refname>
<refpurpose>Execution</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <type>void</type><methodname>Threaded::run</methodname>
<void />
</methodsynopsis>
<para>
The programmer should always implement the run method for objects that are intended for execution.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
&no.function.parameters;
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
The methods return value, if used, will be ignored
</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,48 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision: 332046 $ -->
<refentry xml:id="threaded.shift" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>Threaded::shift</refname>
<refpurpose>Manipulation</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <type>boolean</type><methodname>Threaded::shift</methodname>
<void />
</methodsynopsis>
<para>
Shifts an item from the objects property table
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
The first item from the objects property table
</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,107 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision: 328988 $ -->
<refentry xml:id="threaded.synchronized" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>Threaded::synchronized</refname>
<refpurpose>Synchronization</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <type>mixed</type><methodname>Threaded::synchronized</methodname>
<methodparam><type>Closure</type><parameter>block</parameter></methodparam>
<methodparam choice="opt"><type>mixed</type><parameter>...</parameter></methodparam>
</methodsynopsis>
<para>
Executes the block while retaining the referenced objects synchronization lock for the calling context
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<variablelist>
<varlistentry>
<term><parameter>block</parameter></term>
<listitem>
<para>
The block of code to execute
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>...</parameter></term>
<listitem>
<para>
Variable length list of arguments to use as function arguments to the block
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
The return value from the block
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Synchronizing</title>
<programlisting role="php">
<![CDATA[
<?php
class My extends Thread {
public function run() {
$this->synchronized(function($thread){
if (!$thread->done)
$thread->wait();
}, $this);
}
}
$my = new My();
$my->start();
$my->synchronized(function($thread){
$thread->done = true;
$thread->notify();
}, $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

@ -1,16 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- $Revision: 328988 $ -->
<refentry xml:id="thread.unlock" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refentry xml:id="threaded.unlock" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>Thread::unlock</refname>
<refname>Threaded::unlock</refname>
<refpurpose>Synchronization</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>final</modifier> <modifier>public</modifier> <type>boolean</type><methodname>Thread::unlock</methodname>
<modifier>public</modifier> <type>boolean</type><methodname>Threaded::unlock</methodname>
<void />
</methodsynopsis>
<para>
@ -34,7 +34,7 @@
&reftitle.examples;
<para>
<example>
<title>Locking Thread Storage</title>
<title>Locking Object Storage</title>
<programlisting role="php">
<![CDATA[
<?php

View file

@ -0,0 +1,100 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision: 328967 $ -->
<refentry xml:id="threaded.wait" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>Threaded::wait</refname>
<refpurpose>Synchronization</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <type>boolean</type><methodname>Threaded::wait</methodname>
<methodparam choice="opt"><type>integer</type><parameter>timeout</parameter></methodparam>
</methodsynopsis>
<para>
Will cause the calling context to wait for notification from the referenced object
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<variablelist>
<varlistentry>
<term><parameter>timeout</parameter></term>
<listitem>
<para>
An optional timeout in microseconds
</para>
</listitem>
</varlistentry>
</variablelist>
</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->notify();
}, $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

@ -5,83 +5,109 @@
-->
<versions>
<!-- Methods -->
<!-- Classes and Methods -->
<function name='thread' from='PECL pthreads &gt;= 0.34'/>
<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'/>
<function name='thread::notify' from='PECL pthreads &gt;= 0.34'/>
<function name='thread::join' from='PECL pthreads &gt;= 0.34'/>
<function name='thread::isstarted' from='PECL pthreads &gt;= 0.34'/>
<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'/>
<function name='thread::lock' from='PECL pthreads &gt;= 0.40'/>
<function name='thread::unlock' from='PECL pthreads &gt;= 0.40'/>
<function name='thread::shift' from='PECL pthreads &gt;= 0.45'/>
<function name='thread::pop' from='PECL pthreads &gt;= 0.45'/>
<function name='thread::merge' from='PECL pthreads &gt;= 0.45'/>
<function name='thread::chunk' from='PECL pthreads &gt;= 0.45'/>
<function name='thread::kill' from='PECL pthreads &gt;= 0.46'/>
<function name='threaded' from='PECL pthreads &gt;= 2.0.0'/>
<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::isrunning' from='PECL pthreads &gt;= 2.0.0'/>
<function name='threaded::iswaiting' from='PECL pthreads &gt;= 2.0.0'/>
<function name='threaded::isterminated' from='PECL pthreads &gt;= 2.0.0'/>
<function name='threaded::getterminationinfo' from='PECL pthreads &gt;= 2.0.0'/>
<function name='threaded::synchronized' from='PECL pthreads &gt;= 2.0.0'/>
<function name='threaded::lock' from='PECL pthreads &gt;= 2.0.0'/>
<function name='threaded::unlock' from='PECL pthreads &gt;= 2.0.0'/>
<function name='threaded::merge' from='PECL pthreads &gt;= 2.0.0'/>
<function name='threaded::shift' from='PECL pthreads &gt;= 2.0.0'/>
<function name='threaded::chunk' from='PECL pthreads &gt;= 2.0.0'/>
<function name='threaded::pop' from='PECL pthreads &gt;= 2.0.0'/>
<function name='threaded::count' from='PECL pthreads &gt;= 2.0.0'/>
<function name='worker' from='PECL pthreads &gt;= 0.36'/>
<function name='worker::start' from='PECL pthreads &gt;= 0.36'/>
<function name='worker::run' from='PECL pthreads &gt;= 0.36'/>
<function name='worker::shutdown' from='PECL pthreads &gt;= 0.37'/>
<function name='worker::getthreadid' from='PECL pthreads &gt;= 0.36'/>
<function name='worker::getcreatorid' from='PECL pthreads &gt;= 0.36'/>
<function name='worker::stack' from='PECL pthreads &gt;= 0.36'/>
<function name='worker::unstack' from='PECL pthreads &gt;= 0.36'/>
<function name='worker::isshutdown' from='PECL pthreads &gt;= 0.37'/>
<function name='worker::isworking' from='PECL pthreads &gt;= 0.37'/>
<function name='worker::getstacked' from='PECL pthreads &gt;= 0.36'/>
<function name='worker::shift' from='PECL pthreads &gt;= 0.45'/>
<function name='worker::pop' from='PECL pthreads &gt;= 0.45'/>
<function name='worker::merge' from='PECL pthreads &gt;= 0.45'/>
<function name='worker::chunk' from='PECL pthreads &gt;= 0.45'/>
<function name='worker::kill' from='PECL pthreads &gt;= 0.46'/>
<function name='thread' from='PECL pthreads &gt;= 2.0.0'/>
<function name='thread::start' from='PECL pthreads &gt;= 2.0.0'/>
<function name='thread::join' from='PECL pthreads &gt;= 2.0.0'/>
<function name='thread::detach' from='PECL pthreads &gt;= 2.0.0'/>
<function name='thread::isstarted' from='PECL pthreads &gt;= 2.0.0'/>
<function name='thread::isjoined' from='PECL pthreads &gt;= 2.0.0'/>
<function name='thread::getthreadid' from='PECL pthreads &gt;= 2.0.0'/>
<function name='thread::getcreatorid' from='PECL pthreads &gt;= 2.0.0'/>
<function name='thread::getcurrentthreadid' from='PECL pthreads &gt;= 2.0.0'/>
<function name='thread::getcurrentthread' from='PECL pthreads &gt;= 2.0.0'/>
<function name='thread::kill' from='PECL pthreads &gt;= 2.0.0'/>
<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='thread::isrunning' from='PECL pthreads &gt;= 2.0.0'/>
<function name='thread::iswaiting' from='PECL pthreads &gt;= 2.0.0'/>
<function name='thread::isterminated' from='PECL pthreads &gt;= 2.0.0'/>
<function name='thread::getterminationinfo' from='PECL pthreads &gt;= 2.0.0'/>
<function name='thread::synchronized' from='PECL pthreads &gt;= 2.0.0'/>
<function name='thread::lock' from='PECL pthreads &gt;= 2.0.0'/>
<function name='thread::unlock' from='PECL pthreads &gt;= 2.0.0'/>
<function name='thread::merge' from='PECL pthreads &gt;= 2.0.0'/>
<function name='thread::shift' from='PECL pthreads &gt;= 2.0.0'/>
<function name='thread::chunk' from='PECL pthreads &gt;= 2.0.0'/>
<function name='thread::pop' from='PECL pthreads &gt;= 2.0.0'/>
<function name='thread::count' from='PECL pthreads &gt;= 2.0.0'/>
<function name='stackable' from='PECL pthreads &gt;= 0.36'/>
<function name='stackable::run' from='PECL pthreads &gt;= 0.36'/>
<function name='stackable::wait' from='PECL pthreads &gt;= 0.36'/>
<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'/>
<function name='stackable::shift' from='PECL pthreads &gt;= 0.45'/>
<function name='stackable::pop' from='PECL pthreads &gt;= 0.45'/>
<function name='stackable::merge' from='PECL pthreads &gt;= 0.45'/>
<function name='stackable::chunk' from='PECL pthreads &gt;= 0.45'/>
<function name='pool::__construct' from='PECL pthreads &gt;= 1.0.0'/>
<function name='pool::resize' from='PECL pthreads &gt;= 1.0.0'/>
<function name='pool::submit' from='PECL pthreads &gt;= 1.0.0'/>
<function name='pool::submitTo' from='PECL pthreads &gt;= 1.0.0'/>
<function name='pool::collect' from='PECL pthreads &gt;= 1.0.0'/>
<function name='pool::shutdown' from='PECL pthreads &gt;= 1.0.0'/>
<function name='pool::__destruct' from='PECL pthreads &gt;= 1.0.0'/>
<function name='mutex' from='PECL pthreads &gt;= 0.34'/>
<function name='mutex::create' from='PECL pthreads &gt;= 0.34'/>
<function name='mutex::lock' from='PECL pthreads &gt;= 0.34'/>
<function name='mutex::trylock' from='PECL pthreads &gt;= 0.34'/>
<function name='mutex::unlock' from='PECL pthreads &gt;= 0.34'/>
<function name='mutex::destroy' from='PECL pthreads &gt;= 0.34'/>
<function name='worker' from='PECL pthreads &gt;= 2.0.0'/>
<function name='worker::shutdown' from='PECL pthreads &gt;= 2.0.0'/>
<function name='worker::stack' from='PECL pthreads &gt;= 2.0.0'/>
<function name='worker::unstack' from='PECL pthreads &gt;= 2.0.0'/>
<function name='worker::getstacked' from='PECL pthreads &gt;= 2.0.0'/>
<function name='worker::isshutdown' from='PECL pthreads &gt;= 2.0.0'/>
<function name='worker::isworking' from='PECL pthreads &gt;= 2.0.0'/>
<function name='worker::start' from='PECL pthreads &gt;= 2.0.0'/>
<function name='worker::join' from='PECL pthreads &gt;= 2.0.0'/>
<function name='worker::detach' from='PECL pthreads &gt;= 2.0.0'/>
<function name='worker::isstarted' from='PECL pthreads &gt;= 2.0.0'/>
<function name='worker::isjoined' from='PECL pthreads &gt;= 2.0.0'/>
<function name='worker::getthreadid' from='PECL pthreads &gt;= 2.0.0'/>
<function name='worker::getcreatorid' from='PECL pthreads &gt;= 2.0.0'/>
<function name='worker::getcurrentthreadid' from='PECL pthreads &gt;= 2.0.0'/>
<function name='worker::getcurrentthread' from='PECL pthreads &gt;= 2.0.0'/>
<function name='worker::kill' from='PECL pthreads &gt;= 2.0.0'/>
<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='worker::isrunning' from='PECL pthreads &gt;= 2.0.0'/>
<function name='worker::iswaiting' from='PECL pthreads &gt;= 2.0.0'/>
<function name='worker::isterminated' from='PECL pthreads &gt;= 2.0.0'/>
<function name='worker::getterminationinfo' from='PECL pthreads &gt;= 2.0.0'/>
<function name='worker::synchronized' from='PECL pthreads &gt;= 2.0.0'/>
<function name='worker::lock' from='PECL pthreads &gt;= 2.0.0'/>
<function name='worker::unlock' from='PECL pthreads &gt;= 2.0.0'/>
<function name='worker::merge' from='PECL pthreads &gt;= 2.0.0'/>
<function name='worker::shift' from='PECL pthreads &gt;= 2.0.0'/>
<function name='worker::chunk' from='PECL pthreads &gt;= 2.0.0'/>
<function name='worker::pop' from='PECL pthreads &gt;= 2.0.0'/>
<function name='worker::count' from='PECL pthreads &gt;= 2.0.0'/>
<function name='cond' from='PECL pthreads &gt;= 0.34'/>
<function name='cond::create' from='PECL pthreads &gt;= 0.34'/>
<function name='cond::signal' from='PECL pthreads &gt;= 0.34'/>
<function name='cond::wait' from='PECL pthreads &gt;= 0.34'/>
<function name='cond::broadcast' from='PECL pthreads &gt;= 0.34'/>
<function name='cond::destroy' from='PECL pthreads &gt;= 0.34'/>
<function name='mutex' from='PECL pthreads &gt;= 2.0.0'/>
<function name='mutex::__construct' from='PECL pthreads &gt;= 2.0.0'/>
<function name='mutex::create' from='PECL pthreads &gt;= 2.0.0'/>
<function name='mutex::lock' from='PECL pthreads &gt;= 2.0.0'/>
<function name='mutex::trylock' from='PECL pthreads &gt;= 2.0.0'/>
<function name='mutex::unlock' from='PECL pthreads &gt;= 2.0.0'/>
<function name='mutex::destroy' from='PECL pthreads &gt;= 2.0.0'/>
<function name='cond' from='PECL pthreads &gt;= 2.0.0'/>
<function name='cond::__construct' from='PECL pthreads &gt;= 2.0.0'/>
<function name='cond::create' from='PECL pthreads &gt;= 2.0.0'/>
<function name='cond::signal' from='PECL pthreads &gt;= 2.0.0'/>
<function name='cond::wait' from='PECL pthreads &gt;= 2.0.0'/>
<function name='cond::broadcast' from='PECL pthreads &gt;= 2.0.0'/>
<function name='cond::destroy' from='PECL pthreads &gt;= 2.0.0'/>
<function name='pool' from='PECL pthreads &gt;= 2.0.0'/>
<function name='pool::__construct' from='PECL pthreads &gt;= 2.0.0'/>
<function name='pool::resize' from='PECL pthreads &gt;= 2.0.0'/>
<function name='pool::submit' from='PECL pthreads &gt;= 2.0.0'/>
<function name='pool::submitto' from='PECL pthreads &gt;= 2.0.0'/>
<function name='pool::collect' from='PECL pthreads &gt;= 2.0.0'/>
<function name='pool::shutdown' from='PECL pthreads &gt;= 2.0.0'/>
<function name='pool::__destruct' from='PECL pthreads &gt;= 2.0.0'/>
</versions>
<!-- Keep this comment at the end of the file

View file

@ -3,7 +3,7 @@
<phpdoc:classref xml:id="class.worker" xmlns:phpdoc="http://php.net/ns/phpdoc" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude">
<title>The Worker class</title>
<title>Workers</title>
<titleabbrev>Worker</titleabbrev>
<partintro>
@ -12,8 +12,24 @@
<section xml:id="worker.intro">
&reftitle.intro;
<para>
Worker Threads have a persistent context, as such should be used over Threads in most cases.
Worker Threads have a persistent context, as such should be used over Threads in most cases.
</para>
<para>
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:
- the Worker goes out of scope (no more references remain)
- the programmer calls shutdown
- the script dies
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>
<warning>
<para>
The programmer must retain references to stacked objects until they are executed or unstacked; the Pool class provides a higher level abstraction
of the Worker functionality and manages references for the programmer.
</para>
</warning>
</section>
<!-- }}} -->
@ -29,11 +45,32 @@
<ooclass>
<classname>Worker</classname>
</ooclass>
<ooclass>
<modifier>extends</modifier>
<classname>Thread</classname>
</ooclass>
<oointerface>
<interfacename>Traversable</interfacename>
</oointerface>
<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[1])" />
<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')])" />
</classsynopsis>
<!-- }}} -->

View file

@ -10,11 +10,11 @@
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>final</modifier> <modifier>public</modifier> <type>int</type><methodname>Worker::getStacked</methodname>
<modifier>public</modifier> <type>integer</type><methodname>Worker::getStacked</methodname>
<void />
</methodsynopsis>
<para>
Returns the number of Stackables waiting to be executed by the referenced Worker
Returns the number of objects waiting to be executed by the referenced Worker
</para>
</refsect1>
@ -26,7 +26,7 @@
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
An integral value
An numeric value
</para>
</refsect1>
@ -38,22 +38,17 @@
<programlisting role="php">
<![CDATA[
<?php
class Work extends Stackable {
class Work extends Threaded {
/** ... **/
public function run(){
/** ... **/
}
}
class My extends Worker {
public function run(){
/** ... **/
}
}
$my = new My();
$my = new Worker();
/** ... **/
$my->stack(new Work());
$work = new Work();
$my->stack($work);
/** ... **/
printf("My worker has %d jobs remaining\n", $my->getStacked());
/** ... **/

View file

@ -10,7 +10,7 @@
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>final</modifier> <modifier>public</modifier> <type>boolean</type><methodname>Worker::isShutdown</methodname>
<modifier>public</modifier> <type>boolean</type><methodname>Worker::isShutdown</methodname>
<void />
</methodsynopsis>
<para>
@ -39,12 +39,7 @@
<programlisting role="php">
<![CDATA[
<?php
class My extends Worker {
public function run() {
/* ... */
}
}
$my = new My();
$my = new Worker();
$my->start();
var_dump($my->isShutdown());
$my->shutdown();

View file

@ -10,7 +10,7 @@
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>final</modifier> <modifier>public</modifier> <type>boolean</type><methodname>Worker::isWorking</methodname>
<modifier>public</modifier> <type>boolean</type><methodname>Worker::isWorking</methodname>
<void />
</methodsynopsis>
<para>
@ -38,12 +38,7 @@
<programlisting role="php">
<![CDATA[
<?php
class My extends Worker {
public function run() {
/* ... */
}
}
$my = new My();
$my = new Worker();
$my->start();
/* ... */
if ($my->isWorking()) {

View file

@ -10,11 +10,11 @@
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>final</modifier> <modifier>public</modifier> <type>boolean</type><methodname>Worker::shutdown</methodname>
<modifier>public</modifier> <type>boolean</type><methodname>Worker::shutdown</methodname>
<void />
</methodsynopsis>
<para>
Shuts down the Worker after executing all the Stackables previously stacked
Shuts down the Worker after executing all the objects previously stacked
</para>
</refsect1>
@ -38,12 +38,7 @@
<programlisting role="php">
<![CDATA[
<?php
class My extends Worker {
public function run() {
/* ... */
}
}
$my = new My();
$my = new Worker();
$my->start();
/* ... */
var_dump($my->shutdown());

View file

@ -10,11 +10,11 @@
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>final</modifier> <modifier>public</modifier> <type>int</type><methodname>Worker::stack</methodname>
<methodparam><type>Stackable</type><parameter>work</parameter></methodparam>
<modifier>public</modifier> <type>integer</type><methodname>Worker::stack</methodname>
<methodparam><type>Threaded</type><parameter role="reference">work</parameter></methodparam>
</methodsynopsis>
<para>
Appends the referenced Stackable to the stack of the referenced Worker
Appends the referenced object to the stack of the referenced Worker
</para>
</refsect1>
@ -25,7 +25,7 @@
<term><parameter>work</parameter></term>
<listitem>
<para>
An object of type Stackable to be executed by the referenced Worker
Threaded object to be executed by the referenced Worker
</para>
</listitem>
</varlistentry>
@ -43,11 +43,11 @@
&reftitle.examples;
<para>
<example>
<title>Passing Stackables to Workers for execution in the Worker Thread</title>
<title>Stacking objects for execution in Workers</title>
<programlisting role="php">
<![CDATA[
<?php
class Work extends Stackable {
class Work extends Threaded {
/** ... **/
public function run(){
@ -55,14 +55,10 @@ class Work extends Stackable {
}
}
class My extends Worker {
public function run(){
/** ... **/
}
}
$my = new My();
$my = new Worker();
$work = new Work();
/** ... **/
var_dump($my->stack(new Work()));
var_dump($my->stack($work));
/** ... **/
?>
]]>

View file

@ -10,11 +10,11 @@
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>final</modifier> <modifier>public</modifier> <type>int</type><methodname>Worker::unstack</methodname>
<methodparam choice="opt"><type>Stackable</type><parameter>work</parameter></methodparam>
<modifier>public</modifier> <type>integer</type><methodname>Worker::unstack</methodname>
<methodparam choice="opt"><type>Threaded</type><parameter role="reference">work</parameter></methodparam>
</methodsynopsis>
<para>
Removes the referenced Stackable ( or all Stackables if parameters are void ) from stack of the referenced Worker
Removes the referenced object ( or all objects if parameters are void ) from stack of the referenced Worker
</para>
</refsect1>
@ -25,7 +25,7 @@
<term><parameter>work</parameter></term>
<listitem>
<para>
An object of type Stackable
Threaded object previously stacked onto Worker
</para>
</listitem>
</varlistentry>
@ -43,22 +43,17 @@
&reftitle.examples;
<para>
<example>
<title>Removing Stackables from Workers</title>
<title>Removing objects from the stack of Workers</title>
<programlisting role="php">
<![CDATA[
<?php
class Work extends Stackable {
class Work extends Threaded {
public function run() {
}
}
class My extends Worker {
public function run() {
/** ... **/
}
}
$my = new My();
$my = new Worker();
$work = new Work();
var_dump($my->stack($work));
var_dump($my->unstack($work));