Remove PHT docs (#1530)

See https://github.com/tpunt/pht/issues/11
This commit is contained in:
George Peter Banyard 2022-04-20 12:39:11 +01:00 committed by GitHub
parent 6d48923b82
commit ee12b637d1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
49 changed files with 0 additions and 4249 deletions

View file

@ -115,7 +115,6 @@
<listitem><simpara><xref linkend="book.pgsql"/></simpara></listitem>
<listitem><simpara><xref linkend="book.phar"/></simpara></listitem>
<listitem><simpara><xref linkend="book.phpdbg"/></simpara></listitem>
<listitem><simpara><xref linkend="book.pht"/></simpara></listitem>
<listitem><simpara><xref linkend="book.posix"/></simpara></listitem>
<listitem><simpara><xref linkend="book.ps"/></simpara></listitem>
<listitem><simpara><xref linkend="book.pspell"/></simpara></listitem>
@ -289,7 +288,6 @@
<listitem><para><xref linkend="ref.pdo-pgsql"/></para></listitem>
<listitem><para><xref linkend="ref.pdo-sqlite"/></para></listitem>
<listitem><para><xref linkend="book.pgsql"/></para></listitem>
<listitem><para><xref linkend="book.pht"/></para></listitem>
<listitem><para><xref linkend="book.pspell"/></para></listitem>
<listitem><para><xref linkend="book.readline"/></para></listitem>
<listitem><para><xref linkend="book.simplexml"/></para></listitem>
@ -351,7 +349,6 @@
<listitem><para><xref linkend="ref.pdo-ibm"/></para></listitem>
<listitem><para><xref linkend="ref.pdo-informix"/></para></listitem>
<listitem><para><xref linkend="ref.pdo-sqlsrv"/></para></listitem>
<listitem><para><xref linkend="book.pht"/></para></listitem>
<listitem><para><xref linkend="book.ps"/></para></listitem>
<listitem><para><xref linkend="book.pthreads"/></para></listitem>
<listitem><para><xref linkend="book.radius"/></para></listitem>

View file

@ -1,81 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="pht-atomicinteger.construct" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>pht\AtomicInteger::__construct</refname>
<refpurpose>AtomicInteger creation</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<constructorsynopsis>
<modifier>public</modifier> <methodname>pht\AtomicInteger::__construct</methodname>
<methodparam choice="opt"><type>int</type><parameter>value</parameter><initializer>0</initializer></methodparam>
</constructorsynopsis>
<para>
Handles the creation of a new atomic integer.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<variablelist>
<varlistentry>
<term><parameter>value</parameter></term>
<listitem>
<para>
The value to initialise the atomic integer to.
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Creating a new atomic integer</title>
<programlisting role="php">
<![CDATA[
<?php
use pht\AtomicInteger;
$atomicInteger = new AtomicInteger(100);
var_dump($atomicInteger->get());
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
int(100)
]]>
</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,86 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="pht-atomicinteger.dec" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>pht\AtomicInteger::dec</refname>
<refpurpose>Decrements the atomic integer's value by one</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <type>void</type><methodname>pht\AtomicInteger::dec</methodname>
<void />
</methodsynopsis>
<para>
This method will decrement the atomic integer's value by one. Internally,
the mutex lock of the atomic integer will be acquired, and so there is no
need to manually acquire it (unless this operation needs to be grouped with
other operations on the same atomic integer - see the example in
<methodname>pht\AtomicInteger::lock</methodname> for a demonstration of this).
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
&no.function.parameters;
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
No return value.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Decrementing an atomic integer's value</title>
<programlisting role="php">
<![CDATA[
<?php
use pht\AtomicInteger;
$atomicInteger = new AtomicInteger();
$atomicInteger->dec();
$atomicInteger->dec();
var_dump($atomicInteger->get());
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
int(-2)
]]>
</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,83 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="pht-atomicinteger.get" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>pht\AtomicInteger::get</refname>
<refpurpose>Gets the atomic integer's value</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <type>int</type><methodname>pht\AtomicInteger::get</methodname>
<void />
</methodsynopsis>
<para>
This method will fetch the current value of the atomic integer. Internally,
the mutex lock of the atomic integer will be acquired, and so there is no
need to manually acquire it (unless this operation needs to be grouped with
other operations on the same atomic integer - see the example in
<methodname>pht\AtomicInteger::lock</methodname> for a demonstration of this).
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
&no.function.parameters;
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
The current integer value of the atomic integer.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Getting an atomic integer's value</title>
<programlisting role="php">
<![CDATA[
<?php
use pht\AtomicInteger;
$atomicInteger = new AtomicInteger(2);
var_dump($atomicInteger->get());
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
int(2)
]]>
</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,86 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="pht-atomicinteger.inc" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>pht\AtomicInteger::inc</refname>
<refpurpose>Increments the atomic integer's value by one</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <type>void</type><methodname>pht\AtomicInteger::inc</methodname>
<void />
</methodsynopsis>
<para>
This method will increment the atomic integer's value by one. Internally,
the mutex lock of the atomic integer will be acquired, and so there is no
need to manually acquire it (unless this operation needs to be grouped with
other operations on the same atomic integer - see the example in
<methodname>pht\AtomicInteger::lock</methodname> for a demonstration of this).
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
&no.function.parameters;
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
No return value.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Incrementing an atomic integer's value</title>
<programlisting role="php">
<![CDATA[
<?php
use pht\AtomicInteger;
$atomicInteger = new AtomicInteger();
$atomicInteger->inc();
$atomicInteger->inc();
var_dump($atomicInteger->get());
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
int(2)
]]>
</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,92 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="pht-atomicinteger.lock" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>pht\AtomicInteger::lock</refname>
<refpurpose>Acquires the atomic integer's mutex lock</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <type>void</type><methodname>pht\AtomicInteger::lock</methodname>
<void />
</methodsynopsis>
<para>
This method will acquire the mutex lock associated with the atomic integer.
The mutex lock only needs to be acquired when needing to group together
multiple operations.
</para>
<para>
The mutex locks of the atomic values are reentrant safe. It is therefore
valid for the same thread to reacquire a mutex lock that it has already
acquired.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
&no.function.parameters;
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
No return value.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Grouping together an atomic integer's operations (requiring a mutex lock)</title>
<programlisting role="php">
<![CDATA[
<?php
use pht\AtomicInteger;
$atomicInteger = new AtomicInteger(2);
// assumes $atomicInteger is being used by multiple threads
$atomicInteger->lock();
$atomicInteger->set($atomicInteger->get() * 2); // double the value
$atomicInteger->unlock();
var_dump($atomicInteger->get());
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
int(4)
]]>
</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,94 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="pht-atomicinteger.set" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>pht\AtomicInteger::set</refname>
<refpurpose>Sets the atomic integer's value</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <type>void</type><methodname>pht\AtomicInteger::set</methodname>
<methodparam><type>int</type><parameter>value</parameter></methodparam>
</methodsynopsis>
<para>
This method will set the value of the atomic integer. Internally, the mutex
lock of the atomic integer will be acquired, and so there is no need to
manually acquire it (unless this operation needs to be grouped with other
operations on the same atomic integer - see the example in
<methodname>pht\AtomicInteger::lock</methodname> for a demonstration of this).
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<variablelist>
<varlistentry>
<term><parameter>value</parameter></term>
<listitem>
<para>
The value to set the atomic integer to.
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
No return value.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Setting an atomic integer's value</title>
<programlisting role="php">
<![CDATA[
<?php
use pht\AtomicInteger;
$atomicInteger = new AtomicInteger();
$atomicInteger->set(20);
var_dump($atomicInteger->get());
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
int(20)
]]>
</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,84 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="pht-atomicinteger.unlock" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>pht\AtomicInteger::unlock</refname>
<refpurpose>Releases the atomic integer's mutex lock</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <type>void</type><methodname>pht\AtomicInteger::unlock</methodname>
<void />
</methodsynopsis>
<para>
This method will release the mutex lock associated with the atomic integer.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
&no.function.parameters;
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
No return value.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Grouping together an atomic integer's operations (requiring a mutex lock)</title>
<programlisting role="php">
<![CDATA[
<?php
use pht\AtomicInteger;
$atomicInteger = new AtomicInteger(2);
// assumes $atomicInteger is being used by multiple threads
$atomicInteger->lock();
$atomicInteger->set($atomicInteger->get() * 2); // double the value
$atomicInteger->unlock();
var_dump($atomicInteger->get());
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
int(4)
]]>
</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,85 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<book xml:id="book.pht" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>pht</title>
<preface xml:id="intro.pht">
&reftitle.intro;
<para>
pht is a new threading extension for PHP. It enables for classes, functions,
and even entire files to be threaded. Currently, pht can only be used with
PHP 7.2. This is due to ZTS mode being unsafe in PHP 7.0 and 7.1. Support
for PHP &gt;7.2 is coming soon.
</para>
<warning>
<para>
The pht extension should not be used in a web server environment. Threading
should be restricted to CLI-based applications only.
</para>
</warning>
<para>
The approach to threading that pht takes is to abstract away the thread
itself behind a dedicated object (<classname>pht\Thread</classname>). Tasks are
then added to the thread's internal task queue, where they are processed
when the thread is started (via <methodname>pht\Thread::start</methodname>).
</para>
<para>
All thread tasks will execute in isolation inside of the newly spawned
thread. For class tasks, this means the spawned objects cannot be passed
around between threads. By keeping the threading contexts completely
separate from one-another, there becomes no need to serialise the properties
of threaded objects (which is a necessary evil if such objects have to
operate in multiple threads).
</para>
<para>
The isolation of threading contexts makes the passing around of data
between them somewhat problematic. To solve this problem, threadable data
structures (<classname>pht\HashTable</classname>, <classname>pht\Vector</classname>,
and <classname>pht\Queue</classname>) have been implemented to allow for a
two-way communication style between threads, where they expose mutex locks
to control their integrity. These data structures can be safely passed
around between threads, and manipulated by multiple threads using the mutex
locks that have been packed in with them. They are reference-counted across
threads, and so they do not need to be explicitly destroyed. This approach
to threading means that only the given built-in data structures need to be
safely passed around between threads.
</para>
<para>
Atomic values are also supported by pht. Currently, only an
<classname>pht\AtomicInteger</classname> class exists. Like the threaded data
structures, it too can safely be passed around between threads.
</para>
</preface>
&reference.pht.setup;
&reference.pht.pht.thread;
&reference.pht.pht.runnable;
&reference.pht.pht.hashtable;
&reference.pht.pht.vector;
&reference.pht.pht.queue;
&reference.pht.pht.atomicinteger;
&reference.pht.pht.threaded;
</book>
<!-- 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,44 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<section xml:id="pht.installation" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
&reftitle.install;
<para>
PHP needs to be built with ZTS (Zend Thread Safety) mode enabled. If PHP is being built from source,
then the <option role="configure">--enable-zts</option> (or on non-Windows systems prior to PHP 8.0.0,
<option role="configure">--enable-maintainer-zts</option>) configuration option must be used.
</para>
<para>
The .so or .dll extension file will need to be included into the &php.ini; file (using the <parameter>extension</parameter> setting).
</para>
<note>
<para>
Windows developers must ensure the <filename>pthreadVC2.dll</filename> file (distributed with the extension's .dll file) is available from the <envar>PATH</envar> environment variable.
</para>
</note>
</section>
<!-- 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,95 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="pht-hashtable.lock" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>pht\HashTable::lock</refname>
<refpurpose>Acquires the hash table's mutex lock</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <type>void</type><methodname>pht\HashTable::lock</methodname>
<void />
</methodsynopsis>
<para>
This method will acquire the mutex lock associated with the hash table. The mutex
lock should always be acquired when manipulating the hash table if it is being
used by multiple threads.
</para>
<para>
The mutex locks of the Inter-Thread Communication (ITC) data structures are
not reentrant. Attempting to reacquire an already-acquired mutex lock by the
same thread will therefore cause a deadlock.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
&no.function.parameters;
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
No return value.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Locking a hash table's mutex lock</title>
<programlisting role="php">
<![CDATA[
<?php
use pht\{Thread, HashTable};
$thread = new Thread();
$hashTable = new HashTable();
$thread->addFunctionTask(function ($hashTable) {
$hashTable->lock();
$hashTable['a'] = 1;
$hashTable->unlock();
}, $hashTable);
$thread->start();
// $hashTable is currently being used by multiple threads
$hashTable->lock();
$hashTable['b'] = 2;
$hashTable->unlock();
$thread->join();
]]>
</programlisting>
</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,84 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="pht-hashtable.size" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>pht\HashTable::size</refname>
<refpurpose>Gets the size of the hash table</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <type>int</type><methodname>pht\HashTable::size</methodname>
<void />
</methodsynopsis>
<para>
Returns the current size of the hash table. This operation requires a
<classname>pht\HashTable</classname>'s mutex lock to be held if it is being used
by multiple threads.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
&no.function.parameters;
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
The size of the hash table.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Getting a hash table's size</title>
<programlisting role="php">
<![CDATA[
<?php
use pht\HashTable;
$hashTable = new HashTable();
$hashTable['a'] = 1;
$hashTable['b'] = 2;
var_dump($hashTable->size());
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
int(2)
]]>
</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,87 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="pht-hashtable.unlock" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>pht\HashTable::unlock</refname>
<refpurpose>Releases the hash table's mutex lock</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <type>void</type><methodname>pht\HashTable::unlock</methodname>
<void />
</methodsynopsis>
<para>
This method will release the mutex lock associated with the hash table.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
&no.function.parameters;
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
No return value.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Locking a hash table's mutex lock</title>
<programlisting role="php">
<![CDATA[
<?php
use pht\{Thread, HashTable};
$thread = new Thread();
$hashTable = new HashTable();
$thread->addFunctionTask(function ($hashTable) {
$hashTable->lock();
$hashTable['a'] = 1;
$hashTable->unlock();
}, $hashTable);
$thread->start();
// $hashTable is currently being used by multiple threads
$hashTable->lock();
$hashTable['b'] = 2;
$hashTable->unlock();
$thread->join();
]]>
</programlisting>
</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,86 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<phpdoc:classref xml:id="class.pht-atomicinteger" 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 AtomicInteger class</title>
<titleabbrev>pht\AtomicInteger</titleabbrev>
<partintro>
<!-- {{{ pht\AtomicInteger intro -->
<section xml:id="pht-atomicinteger.intro">
&reftitle.intro;
<para>
The <classname>pht\AtomicInteger</classname> class is currently the only
supported atomic value. It allows for an integer to be safely passed around
between, and manipulated, by multiple threads. The methods exposed by this
class do not need mutex locking, since they will acquire the internal mutex
lock implicitly. <methodname>pht\AtomicInteger::lock</methodname> and
<methodname>pht\AtomicInteger::unlock</methodname> are still exposed, however,
for when multiple operations involving the same
<classname>pht\AtomicInteger</classname> object need to be grouped together.
</para>
<para>
The mutex locks of the atomic values are reentrant safe.
</para>
</section>
<!-- }}} -->
<section xml:id="pht-atomicinteger.synopsis">
&reftitle.classsynopsis;
<!-- {{{ Synopsis -->
<classsynopsis>
<ooclass><classname>pht\AtomicInteger</classname></ooclass>
<!-- {{{ Class synopsis -->
<classsynopsisinfo>
<ooclass>
<classname>pht\AtomicInteger</classname>
</ooclass>
<oointerface>
<interfacename>pht\Threaded</interfacename>
</oointerface>
</classsynopsisinfo>
<!-- }}} -->
<classsynopsisinfo role="comment">&Methods;</classsynopsisinfo>
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.pht-atomicinteger')/db:refentry/db:refsect1[@role='description']/descendant::db:constructorsynopsis[not(@role='procedural')])">
<xi:fallback/>
</xi:include>
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.pht-atomicinteger')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[not(@role='procedural')])">
<xi:fallback/>
</xi:include>
</classsynopsis>
<!-- }}} -->
</section>
</partintro>
&reference.pht.entities.atomicinteger;
</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

@ -1,84 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<phpdoc:classref xml:id="class.pht-hashtable" 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 HashTable class</title>
<titleabbrev>pht\HashTable</titleabbrev>
<partintro>
<!-- {{{ pht\HashTable intro -->
<section xml:id="pht-hashtable.intro">
&reftitle.intro;
<para>
The <classname>pht\HashTable</classname> class is one of the Inter-Thread
Communication (ITC) data structures exposed by pht. It can be safely passed
around between threads, and manipulated by multiple threads using the mutex
locks that have been packed in with the data structure. It is
reference-counted across threads, and so it does not need to be explicitly
destroyed.
</para>
<para>
The <classname>pht\HashTable</classname> class enables for array access upon
its objects (along with the <function>isset</function> and
<function>unset</function> functions). The
<classname>ArrayAccess</classname> interface is not explicitly implemented,
however, because it is only needed for such abilities by userland classes.
</para>
</section>
<!-- }}} -->
<section xml:id="pht-hashtable.synopsis">
&reftitle.classsynopsis;
<!-- {{{ Synopsis -->
<classsynopsis>
<ooclass><classname>pht\HashTable</classname></ooclass>
<!-- {{{ Class synopsis -->
<classsynopsisinfo>
<ooclass>
<classname>pht\HashTable</classname>
</ooclass>
<oointerface>
<interfacename>pht\Threaded</interfacename>
</oointerface>
</classsynopsisinfo>
<!-- }}} -->
<classsynopsisinfo role="comment">&Methods;</classsynopsisinfo>
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.pht-hashtable')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[not(@role='procedural')])" />
</classsynopsis>
<!-- }}} -->
</section>
</partintro>
&reference.pht.entities.hashtable;
</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

@ -1,77 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<phpdoc:classref xml:id="class.pht-queue" 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 Queue class</title>
<titleabbrev>pht\Queue</titleabbrev>
<partintro>
<!-- {{{ pht\Queue intro -->
<section xml:id="pht-queue.intro">
&reftitle.intro;
<para>
The <classname>pht\Queue</classname> class is one of the Inter-Thread
Communication (ITC) data structures exposed by pht. It can be safely passed
around between threads, and manipulated by multiple threads using the mutex
locks that have been packed in with the data structure. It is
reference-counted across threads, and so it does not need to be explicitly
destroyed.
</para>
</section>
<!-- }}} -->
<section xml:id="pht-queue.synopsis">
&reftitle.classsynopsis;
<!-- {{{ Synopsis -->
<classsynopsis>
<ooclass><classname>pht\Queue</classname></ooclass>
<!-- {{{ Class synopsis -->
<classsynopsisinfo>
<ooclass>
<classname>pht\Queue</classname>
</ooclass>
<oointerface>
<interfacename>pht\Threaded</interfacename>
</oointerface>
</classsynopsisinfo>
<!-- }}} -->
<classsynopsisinfo role="comment">&Methods;</classsynopsisinfo>
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.pht-queue')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[not(@role='procedural')])" />
</classsynopsis>
<!-- }}} -->
</section>
</partintro>
&reference.pht.entities.queue;
</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

@ -1,69 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<phpdoc:classref xml:id="class.pht-runnable" 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 Runnable interface</title>
<titleabbrev>pht\Runnable</titleabbrev>
<partintro>
<!-- {{{ pht\Runnable intro -->
<section xml:id="pht-runnable.intro">
&reftitle.intro;
<para>
The <interfacename>pht\Runnable</interfacename> interface enforces the
implementation of a run() method on classes that should be threaded. This
method acts as the entry point of the threaded class.
</para>
</section>
<!-- }}} -->
<section xml:id="pht-runnable.synopsis">
&reftitle.interfacesynopsis;
<!-- {{{ Synopsis -->
<classsynopsis>
<ooclass><classname>pht\Runnable</classname></ooclass>
<!-- {{{ Class synopsis -->
<classsynopsisinfo>
<ooclass>
<classname>pht\Runnable</classname>
</ooclass>
</classsynopsisinfo>
<classsynopsisinfo role="comment">&Methods;</classsynopsisinfo>
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.pht-runnable')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[not(@role='procedural')])" />
</classsynopsis>
<!-- }}} -->
</section>
</partintro>
&reference.pht.entities.runnable;
</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

@ -1,74 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<phpdoc:classref xml:id="class.pht-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>
<titleabbrev>pht\Thread</titleabbrev>
<partintro>
<!-- {{{ pht\Thread intro -->
<section xml:id="pht-thread.intro">
&reftitle.intro;
<para>
The <classname>pht\Thread</classname> class abstracts away a native thread. It
has an internal task queue, where the methods
<methodname>pht\Thread::addClassTask</methodname>,
<methodname>pht\Thread::addFunctionTask</methodname>, and
<methodname>pht\Thread::addFileTask</methodname> push new tasks onto this
queue. Invoking the <methodname>pht\Thread::start</methodname> method will
cause the new thread to be spawned, where it will then begin working
through the task queue. A thread may be reused for any number of tasks.
</para>
</section>
<!-- }}} -->
<section xml:id="pht-thread.synopsis">
&reftitle.classsynopsis;
<!-- {{{ Synopsis -->
<classsynopsis>
<ooclass><classname>pht\Thread</classname></ooclass>
<!-- {{{ Class synopsis -->
<classsynopsisinfo>
<ooclass>
<classname>pht\Thread</classname>
</ooclass>
</classsynopsisinfo>
<classsynopsisinfo role="comment">&Methods;</classsynopsisinfo>
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.pht-thread')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[not(@role='procedural')])" />
</classsynopsis>
<!-- }}} -->
</section>
</partintro>
&reference.pht.entities.thread;
</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

@ -1,75 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<phpdoc:classref xml:id="class.pht-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>The Threaded interface</title>
<titleabbrev>pht\Threaded</titleabbrev>
<partintro>
<!-- {{{ pht\Threaded intro -->
<section xml:id="pht-threaded.intro">
&reftitle.intro;
<para>
The <interfacename>pht\Threaded</interfacename> interface is an internal interface used
by the Inter-Thread Communication (ITC) data structures
(<classname>pht\HashTable</classname>, <classname>pht\Queue</classname>, and
<classname>pht\Vector</classname>). It allows those data structures to be
threaded and ensures that the mutex locking API
(<methodname>pht\Threaded::lock</methodname> and
<methodname>pht\Threaded::unlock</methodname>) is implemented by each of the
ITC data structures. It is not implementable by userland classes (since
standalone mutex locks are not exposed).
</para>
</section>
<!-- }}} -->
<section xml:id="pht-threaded.synopsis">
&reftitle.interfacesynopsis;
<!-- {{{ Synopsis -->
<classsynopsis>
<ooclass><classname>pht\Threaded</classname></ooclass>
<!-- {{{ Class synopsis -->
<classsynopsisinfo>
<ooclass>
<classname>pht\Threaded</classname>
</ooclass>
</classsynopsisinfo>
<classsynopsisinfo role="comment">&Methods;</classsynopsisinfo>
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.pht-threaded')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[not(@role='procedural')])" />
</classsynopsis>
<!-- }}} -->
</section>
</partintro>
&reference.pht.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

@ -1,89 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<phpdoc:classref xml:id="class.pht-vector" 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 Vector class</title>
<titleabbrev>pht\Vector</titleabbrev>
<partintro>
<!-- {{{ pht\Vector intro -->
<section xml:id="pht-vector.intro">
&reftitle.intro;
<para>
The <classname>pht\Vector</classname> class is one of the Inter-Thread
Communication (ITC) data structures exposed by pht. It can be safely passed
around between threads, and manipulated by multiple threads using the mutex
locks that have been packed in with the data structure. It is
reference-counted across threads, and so is does not need to be explicitly
destroyed.
</para>
<para>
The <classname>pht\Vector</classname> class enables for array access upon
its objects (along with the <function>isset</function> and
<function>unset</function> functions). The
<classname>ArrayAccess</classname> interface is not explicitly implemented,
however, because it is only needed for such abilities by userland classes.
</para>
</section>
<!-- }}} -->
<section xml:id="pht-vector.synopsis">
&reftitle.classsynopsis;
<!-- {{{ Synopsis -->
<classsynopsis>
<ooclass><classname>pht\Vector</classname></ooclass>
<!-- {{{ Class synopsis -->
<classsynopsisinfo>
<ooclass>
<classname>pht\Vector</classname>
</ooclass>
<oointerface>
<interfacename>pht\Threaded</interfacename>
</oointerface>
</classsynopsisinfo>
<!-- }}} -->
<classsynopsisinfo role="comment">&Methods;</classsynopsisinfo>
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.pht-vector')/db:refentry/db:refsect1[@role='description']/descendant::db:constructorsynopsis[not(@role='procedural')])">
<xi:fallback/>
</xi:include>
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.pht-vector')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[not(@role='procedural')])">
<xi:fallback/>
</xi:include>
</classsynopsis>
<!-- }}} -->
</section>
</partintro>
&reference.pht.entities.vector;
</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

@ -1,129 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="pht-queue.front" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>pht\Queue::front</refname>
<refpurpose>Returns the first value from a queue</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <type>mixed</type><methodname>pht\Queue::front</methodname>
<void />
</methodsynopsis>
<para>
This method will remove a value from the front of the queue (in constant
time). Attempting to return the front value from an empty queue will result
in an <classname>Error</classname> exception.
</para>
<caution>
<para>
Due to the fact that all values in a <classname>pht\Queue</classname> are
serialised, extracting a value from the queue will require it to be
deserialised. This can incur a noticeable performance hit if the inspection
of the queue's front value is performed within a loop.
</para>
</caution>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
&no.function.parameters;
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
The value on the front of the queue.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Retrieving the front value of a queue</title>
<programlisting role="php">
<![CDATA[
<?php
use pht\Queue;
$queue = new Queue();
$queue->push(1);
var_dump($queue->front());
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
int(1)
]]>
</screen>
</example>
</para>
<para>
<example>
<title>Retrieving the front value in a loop (bad example - don't do this)</title>
<programlisting role="php">
<![CDATA[
<?php
use pht\Queue;
$queue = new Queue();
$queue->push(array_fill(0, 2000, 0));
for ($i = 0; $i < count($queue->front()); ++$i); // quadratic runtime
]]>
</programlisting>
</example>
</para>
<para>
<example>
<title>Retrieving the front value in a loop (good example)</title>
<programlisting role="php">
<![CDATA[
<?php
use pht\Queue;
$queue = new Queue();
$queue->push(array_fill(0, 2000, 0));
$front = $queue->front(); // create a separate variable
for ($i = 0; $i < count($front); ++$i); // linear runtime
]]>
</programlisting>
</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,107 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="pht-queue.lock" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>pht\Queue::lock</refname>
<refpurpose>Acquires the queue's mutex lock</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <type>void</type><methodname>pht\Queue::lock</methodname>
<void />
</methodsynopsis>
<para>
This method will acquire the mutex lock associated with the queue. The mutex
lock should always be acquired when manipulating the queue if it is being
used by multiple threads.
</para>
<para>
The mutex locks of the Inter-Thread Communication (ITC) data structures are
not reentrant. Attempting to reacquire an already-acquired mutex lock by the
same thread will therefore cause a deadlock.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
&no.function.parameters;
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
No return value.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Locking a queue's mutex lock</title>
<programlisting role="php">
<![CDATA[
<?php
use pht\{Thread, Queue};
$thread = new Thread();
$queue = new Queue();
$thread->addFunctionTask(function ($queue) {
$queue->lock();
$queue->push(1);
$queue->unlock();
}, $queue);
$thread->start();
// $queue is currently being used by multiple threads
$queue->lock();
$queue->push(1);
$queue->unlock();
$thread->join();
// $queue is only being used in this thread now, so no need to lock it
while ($queue->size()) {
var_dump($queue->pop());
}
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
int(1)
int(1)
]]>
</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,83 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="pht-queue.pop" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>pht\Queue::pop</refname>
<refpurpose>Pops a value off of the front of a queue</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <type>mixed</type><methodname>pht\Queue::pop</methodname>
<void />
</methodsynopsis>
<para>
This method will remove a value from the front of the queue (in constant
time). Attempting to pop a value from an empty queue will result in an
<classname>Error</classname> exception.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
&no.function.parameters;
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
The value removed from the queue.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Popping a value from a queue</title>
<programlisting role="php">
<![CDATA[
<?php
use pht\Queue;
$queue = new Queue();
$queue->push(1);
var_dump($queue->pop());
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
int(1)
]]>
</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,94 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="pht-queue.push" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>pht\Queue::push</refname>
<refpurpose>Pushes a value to the end of a queue</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <type>void</type><methodname>pht\Queue::push</methodname>
<methodparam><type>mixed</type><parameter>value</parameter></methodparam>
</methodsynopsis>
<para>
This method will add a value onto the queue.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<variablelist>
<varlistentry>
<term><parameter>value</parameter></term>
<listitem>
<para>
The value to be added to a <classname>pht\Queue</classname>. This value will
be serialised (since it may be passed around between threads).
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
No return value.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Pushing a value to a queue</title>
<programlisting role="php">
<![CDATA[
<?php
use pht\Queue;
$queue = new Queue();
$queue->push(1);
var_dump($queue);
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
object(pht\Queue)#1 (1) {
[0]=>
int(1)
}
]]>
</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,84 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="pht-queue.size" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>pht\Queue::size</refname>
<refpurpose>Gets the size of the queue</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <type>int</type><methodname>pht\Queue::size</methodname>
<void />
</methodsynopsis>
<para>
Returns the current size of the queue. This operation requires a
<classname>pht\Queue</classname>'s mutex lock to be held if it is being used by
multiple threads.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
&no.function.parameters;
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
The size of the queue.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Getting a queue's size</title>
<programlisting role="php">
<![CDATA[
<?php
use pht\Queue;
$queue = new Queue();
$queue->push(1);
$queue->push(1);
var_dump($queue->size());
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
int(2)
]]>
</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,99 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="pht-queue.unlock" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>pht\Queue::unlock</refname>
<refpurpose>Releases the queue's mutex lock</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <type>void</type><methodname>pht\Queue::unlock</methodname>
<void />
</methodsynopsis>
<para>
This method will release the mutex lock associated with the queue.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
&no.function.parameters;
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
No return value.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Locking a queue's mutex lock</title>
<programlisting role="php">
<![CDATA[
<?php
use pht\{Thread, Queue};
$thread = new Thread();
$queue = new Queue();
$thread->addFunctionTask(function ($queue) {
$queue->lock();
$queue->push(1);
$queue->unlock();
}, $queue);
$thread->start();
// $queue is currently being used by multiple threads
$queue->lock();
$queue->push(1);
$queue->unlock();
$thread->join();
// $queue is only being used in this thread now, so no need to lock it
while ($queue->size()) {
var_dump($queue->pop());
}
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
int(1)
int(1)
]]>
</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,54 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="pht-runnable.run" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>pht\Runnable::run</refname>
<refpurpose>The entry point of a threaded class</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <type>void</type><methodname>pht\Runnable::run</methodname>
<void />
</methodsynopsis>
<para>
This method acts as the entry point of execution for a threaded class. It
must be defined by all classes that will be threaded.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
&no.function.parameters;
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
No return value.
</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,62 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<chapter xml:id="pht.setup" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
&reftitle.setup;
<section xml:id="pht.requirements">
&reftitle.required;
<para>
pht requires a ZTS (Zend Thread Safety) version of PHP. Currently, only PHP
7.2 is supported. Support for PHP 7.3 (which will be released at the end of
2018) will be coming soon. PHP 7.0 and 7.1 are unsafe to support, due to
race conditions in ZTS mode.
</para>
<para>
pht should be compatible for any OS with the pthread library (or
pthread-win32 library, which is for Windows).
</para>
</section>
<section xml:id="pht.installation">
&reftitle.install;
<para>
pht releases are hosted (along with its source code) on the
<link xlink:href="&url.git.hub;tpunt/pht">pht GitHub repository</link>. Unix
developers will need to build from source
(<link xlink:href="&url.git.hub;tpunt/pht#installation">instructions here</link>).
Windows developers can download the appropriate .dll file from the
<link xlink:href="&url.git.hub;tpunt/pht/releases">repository's releases page</link>.
They will need to ensure that the provided pthreadVC2.dll file (which is
distributed alongside the extension's .dll file) is made available in their
<envar>PATH</envar> environment variable.
</para>
</section>
<section xml:id="pht.configuration">
&reftitle.runtime;
&no.config;
</section>
</chapter>
<!-- 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,118 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="pht-thread.addClassTask" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>pht\Thread::addClassTask</refname>
<refpurpose>Class threading</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <type>void</type><methodname>pht\Thread::addClassTask</methodname>
<methodparam><type>string</type><parameter>className</parameter></methodparam>
<methodparam rep="repeat"><type>mixed</type><parameter>ctorArgs</parameter></methodparam>
</methodsynopsis>
<para>
Adds a new class task to a <classname>pht\Thread</classname>s internal task queue.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<variablelist>
<varlistentry>
<term><parameter>className</parameter></term>
<listitem>
<para>
The name of the class to be threaded. This class must implement the
<interfacename>pht\Runnable</interfacename> interface.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>ctorArgs</parameter></term>
<listitem>
<para>
An optional list of arguments for the threaded class' constructor. These
arguments will be serialised (since they are being passed to another
thread).
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
No return value.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Adding a new class task to a thread</title>
<programlisting role="php">
<![CDATA[
<?php
use pht\{Thread, Runnable};
class Task implements Runnable
{
private $one;
public function __construct(int $one)
{
$this->one = $one;
}
public function run()
{
var_dump($this->one);
}
}
$thread = new Thread();
$thread->addClassTask(Task::class, 1);
$thread->start();
$thread->join();
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
int(1)
]]>
</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,116 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="pht-thread.addFileTask" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>pht\Thread::addFileTask</refname>
<refpurpose>File threading</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <type>void</type><methodname>pht\Thread::addFileTask</methodname>
<methodparam><type>string</type><parameter>fileName</parameter></methodparam>
<methodparam rep="repeat"><type>mixed</type><parameter>globals</parameter></methodparam>
</methodsynopsis>
<para>
Adds a new file task to a <classname>pht\Thread</classname>s internal task queue.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<variablelist>
<varlistentry>
<term><parameter>func</parameter></term>
<listitem>
<para>
The name of the file to be threaded.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>globals</parameter></term>
<listitem>
<para>
An optional list of arguments for the file. These arguments will be
placed into a <literal>$_THREAD</literal> superglobal, which will be made
available inside of the threaded file. All arguments will be serialised
(since they are being passed to another thread).
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
No return value.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Adding a new file task to a thread</title>
<programlisting role="php">
<![CDATA[
<?php
use pht\Thread;
$thread = new Thread();
$thread->addFileTask('file.php', 1, 2, 3);
$thread->start();
$thread->join();
]]>
</programlisting>
<para>file.php:</para>
<programlisting role="php">
<![CDATA[
<?php
[$one, $two, $three] = $_THREAD;
var_dump($one, $two, $three);
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
int(1)
int(2)
int(3)
]]>
</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,120 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="pht-thread.addFunctionTask" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>pht\Thread::addFunctionTask</refname>
<refpurpose>Function threading</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <type>void</type><methodname>pht\Thread::addFunctionTask</methodname>
<methodparam><type>callable</type><parameter>func</parameter></methodparam>
<methodparam rep="repeat"><type>mixed</type><parameter>funcArgs</parameter></methodparam>
</methodsynopsis>
<para>
Adds a new function task to a <classname>pht\Thread</classname>s internal task queue.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<variablelist>
<varlistentry>
<term><parameter>func</parameter></term>
<listitem>
<para>
The function to be threaded. If it is bound to an instance, then
<literal>$this</literal> will become &null;.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>funcArgs</parameter></term>
<listitem>
<para>
An optional list of arguments for the function. These arguments will be
serialised (since they are being passed to another thread).
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
No return value.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Adding a new function task to a thread</title>
<programlisting role="php">
<![CDATA[
<?php
use pht\Thread;
class Test
{
public static function run(){var_dump(5);}
public static function run2(){var_dump(6);}
}
function aFunc(){var_dump(3);}
$thread = new Thread();
$thread->addFunctionTask(static function($one) {var_dump($one);}, 1);
$thread->addFunctionTask(function() {var_dump(2);});
$thread->addFunctionTask('aFunc');
$thread->addFunctionTask('array_map', function ($n) {var_dump($n);}, [4]);
$thread->addFunctionTask(['Test', 'run']);
$thread->addFunctionTask([new Test, 'run2']);
$thread->start();
$thread->join();
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
int(1)
int(2)
int(3)
int(4)
int(5)
int(6)
]]>
</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,77 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="pht-thread.join" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>pht\Thread::join</refname>
<refpurpose>Joins a thread</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <type>void</type><methodname>pht\Thread::join</methodname>
<void />
</methodsynopsis>
<para>
This method will join the spawned thread (though it will first wait for that
thread's internal task queue to finish). As a matter of good practice,
threads should always be joined. Not joining a thread may lead to undefined
behaviour.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
&no.function.parameters;
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
No return value.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Joining a thread</title>
<programlisting role="php">
<![CDATA[
<?php
use pht\Thread;
$thread = new Thread();
$thread->start();
$thread->join();
]]>
</programlisting>
</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,76 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="pht-thread.start" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>pht\Thread::start</refname>
<refpurpose>Starts the new thread</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <type>void</type><methodname>pht\Thread::start</methodname>
<void />
</methodsynopsis>
<para>
This will cause a new thread to be spawned for the associated
<classname>pht\Thread</classname> object, where its internal task queue will
begin to be processed.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
&no.function.parameters;
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
No return value.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Starting a new thread</title>
<programlisting role="php">
<![CDATA[
<?php
use pht\Thread;
$thread = new Thread();
$thread->start();
$thread->join();
]]>
</programlisting>
</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,83 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="pht-thread.taskCount" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>pht\Thread::taskCount</refname>
<refpurpose>Gets a thread's task count</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <type>int</type><methodname>pht\Thread::taskCount</methodname>
<void />
</methodsynopsis>
<para>
Retrieves the current task count of a <classname>pht\Thread</classname>.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
&no.function.parameters;
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
The number of tasks remaining to be processed.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Getting the task count of a thread</title>
<programlisting role="php">
<![CDATA[
<?php
use pht\Thread;
$thread = new Thread();
$thread->addFunctionTask(function (){});
$thread->addFunctionTask(function (){});
$thread->addFunctionTask(function (){});
var_dump($thread->taskCount());
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
int(3)
]]>
</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,55 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="pht-threaded.lock" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>pht\Threaded::lock</refname>
<refpurpose>Acquires the mutex lock</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <type>void</type><methodname>pht\Threaded::lock</methodname>
<void />
</methodsynopsis>
<para>
This method will acquire the mutex lock associated with the given class
(either a <classname>pht\HashTable</classname>, <classname>pht\Queue</classname>,
<classname>pht\Vector</classname>, or <classname>pht\AtomicInteger</classname>).
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
&no.function.parameters;
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
No return value.
</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,55 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="pht-threaded.unlock" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>pht\Threaded::unlock</refname>
<refpurpose>Releases the mutex lock</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <type>void</type><methodname>pht\Threaded::unlock</methodname>
<void />
</methodsynopsis>
<para>
This method will unlock the mutex lock associated with the given class
(either a <classname>pht\HashTable</classname>, <classname>pht\Queue</classname>,
<classname>pht\Vector</classname>, or <classname>pht\AtomicInteger</classname>).
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
&no.function.parameters;
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
No return value.
</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,100 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="pht-vector.construct" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>pht\Vector::__construct</refname>
<refpurpose>Vector creation</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<constructorsynopsis>
<modifier>public</modifier> <methodname>pht\Vector::__construct</methodname>
<methodparam choice="opt"><type>int</type><parameter>size</parameter><initializer>0</initializer></methodparam>
<methodparam choice="opt"><type>mixed</type><parameter>value</parameter><initializer>0</initializer></methodparam>
</constructorsynopsis>
<para>
Handles the creation of a new vector.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<variablelist>
<varlistentry>
<term><parameter>size</parameter></term>
<listitem>
<para>
The size of the vector that will be created.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>value</parameter></term>
<listitem>
<para>
The value to initialise the empty slots in the vector to.
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Creating a new vector</title>
<programlisting role="php">
<![CDATA[
<?php
use pht\Vector;
$vector1 = new Vector(1);
$vector2 = new Vector(2, 1);
var_dump($vector1, $vector2);
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
object(pht\Vector)#1 (1) {
[0]=>
int(0)
}
object(pht\Vector)#2 (2) {
[0]=>
int(1)
[1]=>
int(1)
}
]]>
</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,111 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="pht-vector.deleteAt" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>pht\Vector::deleteAt</refname>
<refpurpose>Deletes a value in the vector</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <type>void</type><methodname>pht\Vector::deleteAt</methodname>
<methodparam><type>int</type><parameter>offset</parameter></methodparam>
</methodsynopsis>
<para>
This method deletes a value at the specified offset in the vector (in linear
time).
</para>
<para>
Since the <classname>pht\Vector</classname> class supports array access,
deleting values can also be performed using the array subset notation
(<literal>[]</literal>) in combination with the <function>unset</function>
function.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<variablelist>
<varlistentry>
<term><parameter>offset</parameter></term>
<listitem>
<para>
The offset at which the value will be deleted at. This offset must be
within the 0..(N-1) range (inclusive), where N is the size of the vector.
Attempting to delete at offsets outside of this range will result in an
<classname>Error</classname> exception.
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
No return value.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Deleting values in a vector</title>
<programlisting role="php">
<![CDATA[
<?php
use pht\Vector;
$vector = new Vector();
$vector[] = 1;
$vector[] = 2;
$vector[] = 3;
$vector[] = 4;
$vector->deleteAt(1);
unset($vector[1]);
var_dump($vector);
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
object(pht\Vector)#1 (2) {
[0]=>
int(1)
[1]=>
int(4)
}
]]>
</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,117 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="pht-vector.insertAt" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>pht\Vector::insertAt</refname>
<refpurpose>Inserts a value into the vector</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <type>void</type><methodname>pht\Vector::insertAt</methodname>
<methodparam><type>mixed</type><parameter>value</parameter></methodparam>
<methodparam><type>int</type><parameter>offset</parameter></methodparam>
</methodsynopsis>
<para>
This method inserts a value at the specified offset into the vector (in
linear time). The vector will automatically be resized if it is not large
enough.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<variablelist>
<varlistentry>
<term><parameter>value</parameter></term>
<listitem>
<para>
The value to be inserted into the vector. This value will be serialised
(since it may be passed around between threads).
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>offset</parameter></term>
<listitem>
<para>
The offset at which the value will be inserted at. This offset must be
within the 0..N range (inclusive), where N is the size of the vector.
Inserting at position N is the equivalent of using
<methodname>pht\Vector::push</methodname>, and inserting at position 0 is the
equivalent of using <methodname>pht\Vector::unshift</methodname>. Attempting
to insert at offsets outside of this range will result in an
<classname>Error</classname> exception.
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
No return value.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Inserting a value into a vector</title>
<programlisting role="php">
<![CDATA[
<?php
use pht\Vector;
$vector = new Vector();
$vector->insertAt(3, 0); // insert 3 at start
$vector->insertAt(1, 0); // insert 1 at start (before 3)
$vector->insertAt(2, 1); // insert 2 in middle (after 1 and before 3)
var_dump($vector);
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
object(pht\Vector)#1 (3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
}
]]>
</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,95 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="pht-vector.lock" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>pht\Vector::lock</refname>
<refpurpose>Acquires the vector's mutex lock</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <type>void</type><methodname>pht\Vector::lock</methodname>
<void />
</methodsynopsis>
<para>
This method will acquire the mutex lock associated with the vector. The mutex
lock should always be acquired when manipulating the vector if it is being
used by multiple threads.
</para>
<para>
The mutex locks of the Inter-Thread Communication (ITC) data structures are
not reentrant. Attempting to reacquire an already-acquired mutex lock by the
same thread will therefore cause a deadlock.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
&no.function.parameters;
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
No return value.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Locking a vector's mutex lock</title>
<programlisting role="php">
<![CDATA[
<?php
use pht\{Thread, Vector};
$thread = new Thread();
$vector = new Vector();
$thread->addFunctionTask(function ($vector) {
$vector->lock();
$vector[] = 1;
$vector->unlock();
}, $vector);
$thread->start();
// $vector is currently being used by multiple threads
$vector->lock();
$vector[] = 2;
$vector->unlock();
$thread->join();
]]>
</programlisting>
</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,84 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="pht-vector.pop" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>pht\Vector::pop</refname>
<refpurpose>Pops a value to the vector</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <type>mixed</type><methodname>pht\Vector::pop</methodname>
<void />
</methodsynopsis>
<para>
This method pops a value from the end of a vector (in constant time).
Popping a value from an empty vector will result in an
<classname>Error</classname> exception.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
&no.function.parameters;
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
The value from the end of the vector.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Popping a value from a vector</title>
<programlisting role="php">
<![CDATA[
<?php
use pht\Vector;
$vector = new Vector();
$vector->push(1);
$vector[] = 2;
var_dump($vector->pop());
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
int(2)
]]>
</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,103 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="pht-vector.push" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>pht\Vector::push</refname>
<refpurpose>Pushes a value to the vector</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <type>void</type><methodname>pht\Vector::push</methodname>
<methodparam><type>mixed</type><parameter>value</parameter></methodparam>
</methodsynopsis>
<para>
This method pushes a value onto the end of a vector (in constant time). The
vector will automatically be resized if it is not large enough.
</para>
<para>
Since the <classname>pht\Vector</classname> class supports array access, new
values can also be pushed onto the vector using the empty subset notation
(<literal>[]</literal>).
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<variablelist>
<varlistentry>
<term><parameter>value</parameter></term>
<listitem>
<para>
The value to be pushed onto the end of the vector. This value will be
serialised (since it may be passed around between threads).
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
No return value.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Pushing values to a vector</title>
<programlisting role="php">
<![CDATA[
<?php
use pht\Vector;
$vector = new Vector();
$vector->push(1);
$vector[] = 2;
var_dump($vector);
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
object(pht\Vector)#1 (2) {
[0]=>
int(1)
[1]=>
int(2)
}
]]>
</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,116 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="pht-vector.resize" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>pht\Vector::resize</refname>
<refpurpose>Resizes a vector</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <type>void</type><methodname>pht\Vector::resize</methodname>
<methodparam><type>int</type><parameter>size</parameter></methodparam>
<methodparam choice="opt"><type>mixed</type><parameter>value</parameter><initializer>0</initializer></methodparam>
</methodsynopsis>
<para>
Resizes the vector. If it is enlarged, then the <parameter>value</parameter>
parameter will be used to fill in the new slots. If it is made smaller,
then the end values will be truncated.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<variablelist>
<varlistentry>
<term><parameter>size</parameter></term>
<listitem>
<para>
The new size of the vector.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>value</parameter></term>
<listitem>
<para>
The value to initialise the empty vector slots to (only used if the
vector is enlarged).
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
No return value.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Resizing a vector</title>
<programlisting role="php">
<![CDATA[
<?php
use pht\Vector;
$vector = new Vector(1);
var_dump($vector);
$vector->resize(2, 1);
var_dump($vector);
$vector->resize(1, 2); // unused second arg
var_dump($vector);
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
object(pht\Vector)#1 (1) {
[0]=>
int(0)
}
object(pht\Vector)#1 (2) {
[0]=>
int(0)
[1]=>
int(1)
}
object(pht\Vector)#1 (1) {
[0]=>
int(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

@ -1,84 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="pht-vector.shift" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>pht\Vector::shift</refname>
<refpurpose>Shifts a value from the vector</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <type>mixed</type><methodname>pht\Vector::shift</methodname>
<void />
</methodsynopsis>
<para>
This method shifts a value from the front of a vector (in linear time).
Shifting a value from an empty vector will result in an
<classname>Error</classname> exception.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
&no.function.parameters;
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
The value from the front of the vector.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Shifting a value from a vector</title>
<programlisting role="php">
<![CDATA[
<?php
use pht\Vector;
$vector = new Vector();
$vector->push(1);
$vector[] = 2;
var_dump($vector->shift());
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
int(1)
]]>
</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,85 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="pht-vector.size" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>pht\Vector::size</refname>
<refpurpose>Gets the size of the vector</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <type>int</type><methodname>pht\Vector::size</methodname>
<void />
</methodsynopsis>
<para>
Returns the current size of the vector. This operation requires a
<classname>pht\Vector</classname>'s mutex lock to be held if it is being used by
multiple threads.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
&no.function.parameters;
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
The size of the vector.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Getting a vector's size</title>
<programlisting role="php">
<![CDATA[
<?php
use pht\Vector;
$vector = new Vector();
$vector[] = 1;
$vector[] = 2;
$vector[] = 3;
var_dump($vector->size());
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
int(3)
]]>
</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,87 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="pht-vector.unlock" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>pht\Vector::unlock</refname>
<refpurpose>Releases the vector's mutex lock</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <type>void</type><methodname>pht\Vector::unlock</methodname>
<void />
</methodsynopsis>
<para>
This method will release the mutex lock associated with the vector.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
&no.function.parameters;
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
No return value.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Locking a vector's mutex lock</title>
<programlisting role="php">
<![CDATA[
<?php
use pht\{Thread, Vector};
$thread = new Thread();
$vector = new Vector();
$thread->addFunctionTask(function ($vector) {
$vector->lock();
$vector[] = 1;
$vector->unlock();
}, $vector);
$thread->start();
// $vector is currently being used by multiple threads
$vector->lock();
$vector[] = 2;
$vector->unlock();
$thread->join();
]]>
</programlisting>
</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,101 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="pht-vector.unshift" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>pht\Vector::unshift</refname>
<refpurpose>Unshifts a value to the vector front</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <type>void</type><methodname>pht\Vector::unshift</methodname>
<methodparam><type>mixed</type><parameter>value</parameter></methodparam>
</methodsynopsis>
<para>
This method unshifts a value to the front of a vector (in linear time). The
vector will automatically be resized if it is not large enough.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<variablelist>
<varlistentry>
<term><parameter>value</parameter></term>
<listitem>
<para>
The value to be pushed onto the beginning of the vector. This value will
be serialised (since it may be passed around between threads).
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
No return value.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Unshifting a value to the front of a vector</title>
<programlisting role="php">
<![CDATA[
<?php
use pht\Vector;
$vector = new Vector();
for ($i = 0; $i < 3; ++$i) {
$vector->unshift($i); // causes a quadratic runtime, beware
}
var_dump($vector);
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
object(pht\Vector)#1 (3) {
[0]=>
int(2)
[1]=>
int(1)
[2]=>
int(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

@ -1,118 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="pht-vector.updateAt" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>pht\Vector::updateAt</refname>
<refpurpose>Updates a value in the vector</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <type>void</type><methodname>pht\Vector::updateAt</methodname>
<methodparam><type>mixed</type><parameter>value</parameter></methodparam>
<methodparam><type>int</type><parameter>offset</parameter></methodparam>
</methodsynopsis>
<para>
This method updates a value at the specified offset in the vector (in linear
time). The vector will automatically be resized if it is not large enough.
</para>
<para>
Since the <classname>pht\Vector</classname> class supports array access,
updating values can also be performed using the array subset notation
(<literal>[]</literal>).
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<variablelist>
<varlistentry>
<term><parameter>value</parameter></term>
<listitem>
<para>
The value to be inserted into the vector. This value will be serialised
(since it may be passed around between threads).
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>offset</parameter></term>
<listitem>
<para>
The offset at which the value will be updated at. This offset must be
within the 0..(N-1) range (inclusive), where N is the size of the vector.
Attempting to update at offsets outside of this range will result in an
<classname>Error</classname> exception.
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
No return value.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Updating a value in a vector</title>
<programlisting role="php">
<![CDATA[
<?php
use pht\Vector;
$vector = new Vector();
$vector[] = 1;
$vector[] = 2;
$vector->updateAt(3, 0);
$vector[1] = 4;
var_dump($vector);
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
object(pht\Vector)#1 (2) {
[0]=>
int(3)
[1]=>
int(4)
}
]]>
</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,78 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!--
Do NOT translate this file
-->
<versions>
<function name='pht\thread' from='PECL pht &gt;= 0.0.1'/>
<function name='pht\thread::addClassTask' from='PECL pht &gt;= 0.0.1'/>
<function name='pht\thread::addFunctionTask' from='PECL pht &gt;= 0.0.1'/>
<function name='pht\thread::addFileTask' from='PECL pht &gt;= 0.0.1'/>
<function name='pht\thread::taskCount' from='PECL pht &gt;= 0.0.1'/>
<function name='pht\thread::start' from='PECL pht &gt;= 0.0.1'/>
<function name='pht\thread::join' from='PECL pht &gt;= 0.0.1'/>
<function name='pht\runnable' from='PECL pht &gt;= 0.0.1'/>
<function name='pht\runnable::run' from='PECL pht &gt;= 0.0.1'/>
<function name='pht\threaded' from='PECL pht &gt;= 0.0.1'/>
<function name='pht\threaded::lock' from='PECL pht &gt;= 0.0.1'/>
<function name='pht\threaded::unlock' from='PECL pht &gt;= 0.0.1'/>
<function name='pht\queue' from='PECL pht &gt;= 0.0.1'/>
<function name='pht\queue::push' from='PECL pht &gt;= 0.0.1'/>
<function name='pht\queue::pop' from='PECL pht &gt;= 0.0.1'/>
<function name='pht\queue::front' from='PECL pht &gt;= 0.0.1'/>
<function name='pht\queue::size' from='PECL pht &gt;= 0.0.1'/>
<function name='pht\queue::lock' from='PECL pht &gt;= 0.0.1'/>
<function name='pht\queue::unlock' from='PECL pht &gt;= 0.0.1'/>
<function name='pht\hashtable' from='PECL pht &gt;= 0.0.1'/>
<function name='pht\hashtable::size' from='PECL pht &gt;= 0.0.1'/>
<function name='pht\hashtable::lock' from='PECL pht &gt;= 0.0.1'/>
<function name='pht\hashtable::unlock' from='PECL pht &gt;= 0.0.1'/>
<function name='pht\vector' from='PECL pht &gt;= 0.0.1'/>
<function name='pht\vector::__construct' from='PECL pht &gt;= 0.0.1'/>
<function name='pht\vector::resize' from='PECL pht &gt;= 0.0.1'/>
<function name='pht\vector::push' from='PECL pht &gt;= 0.0.1'/>
<function name='pht\vector::pop' from='PECL pht &gt;= 0.0.1'/>
<function name='pht\vector::shift' from='PECL pht &gt;= 0.0.1'/>
<function name='pht\vector::unshift' from='PECL pht &gt;= 0.0.1'/>
<function name='pht\vector::insertAt' from='PECL pht &gt;= 0.0.1'/>
<function name='pht\vector::updateAt' from='PECL pht &gt;= 0.0.1'/>
<function name='pht\vector::deleteAt' from='PECL pht &gt;= 0.0.1'/>
<function name='pht\vector::size' from='PECL pht &gt;= 0.0.1'/>
<function name='pht\vector::lock' from='PECL pht &gt;= 0.0.1'/>
<function name='pht\vector::unlock' from='PECL pht &gt;= 0.0.1'/>
<function name='pht\atomicinteger' from='PECL pht &gt;= 0.0.1'/>
<function name='pht\atomicinteger::__construct' from='PECL pht &gt;= 0.0.1'/>
<function name='pht\atomicinteger::get' from='PECL pht &gt;= 0.0.1'/>
<function name='pht\atomicinteger::set' from='PECL pht &gt;= 0.0.1'/>
<function name='pht\atomicinteger::inc' from='PECL pht &gt;= 0.0.1'/>
<function name='pht\atomicinteger::dec' from='PECL pht &gt;= 0.0.1'/>
<function name='pht\atomicinteger::lock' from='PECL pht &gt;= 0.0.1'/>
<function name='pht\atomicinteger::unlock' from='PECL pht &gt;= 0.0.1'/>
</versions>
<!-- 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
-->