Sophie

Sophie

distrib > Mageia > 7 > armv7hl > by-pkgid > 2b917e0437961edec048f1d15e2d7449 > files > 9224

php-manual-en-7.2.11-1.mga7.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Introduction</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="book.pht.html">pht</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="pht.setup.html">Installing/Configuring</a></div>
 <div class="up"><a href="book.pht.html">pht</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="intro.pht" class="preface">
  <h1 class="title">Introduction</h1>
  <p class="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.
  </p>
  <div class="warning"><strong class="warning">Warning</strong>
   <p class="para">
    The pht extension should not be used in a web server environment. Threading
    should be restricted to CLI-based applications only.
   </p>
  </div>
  <p class="para">
   The approach to threading that pht takes is to abstract away the thread
   itself behind a dedicated object (<a href="class.pht-thread.html" class="classname">pht\Thread</a>). Tasks are
   then added to the thread&#039;s internal task queue, where they are processed
   when the thread is started (via <span class="methodname"><a href="pht-thread.start.html" class="methodname">pht\Thread::start()</a></span>).
  </p>
  <p class="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).
  </p>
  <p class="para">
   The isolation of threading contexts makes the passing around of data
   between them somewhat problematic. To solve this problem, threadable data
   structures (<a href="class.pht-hashtable.html" class="classname">pht\HashTable</a>, <a href="class.pht-vector.html" class="classname">pht\Vector</a>,
   and <a href="class.pht-queue.html" class="classname">pht\Queue</a>) 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.
  </p>
  <p class="para">
   Atomic values are also supported by pht. Currently, only an
   <a href="class.pht-atomicinteger.html" class="classname">pht\AtomicInteger</a> class exists. Like the threaded data
   structures, it too can safely be passed around between threads.
  </p>
 </div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="book.pht.html">pht</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="pht.setup.html">Installing/Configuring</a></div>
 <div class="up"><a href="book.pht.html">pht</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>