mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-15 16:38:54 +00:00

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@344250 c90b9560-bf6c-de11-be94-00142212c4b1
85 lines
3.2 KiB
XML
85 lines
3.2 KiB
XML
<?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 >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
|
|
-->
|