mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
pool documentation
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@332929 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
211f60bb0a
commit
7d4ba55e02
10 changed files with 553 additions and 3 deletions
|
@ -94,6 +94,7 @@
|
|||
&reference.pthreads.worker;
|
||||
&reference.pthreads.stackable;
|
||||
&reference.pthreads.modifiers;
|
||||
&reference.pthreads.pool;
|
||||
&reference.pthreads.mutex;
|
||||
&reference.pthreads.cond;
|
||||
|
||||
|
@ -118,4 +119,4 @@ End:
|
|||
vim600: syn=xml fen fdm=syntax fdl=2 si
|
||||
vim: et tw=78 syn=sgml
|
||||
vi: ts=1 sw=1
|
||||
-->
|
||||
-->
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- $Revision$ -->
|
||||
|
||||
<phpdoc:classref xml:id="class.classname"
|
||||
<phpdoc:classref xml:id="class.pool"
|
||||
xmlns:phpdoc="http://php.net/ns/phpdoc"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
xmlns:xi="http://www.w3.org/2001/XInclude"
|
||||
|
|
48
reference/pthreads/pool/__destruct.xml
Normal file
48
reference/pthreads/pool/__destruct.xml
Normal file
|
@ -0,0 +1,48 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- $Revision: 329926 $ -->
|
||||
|
||||
<refentry xml:id="pool.__destruct" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<refnamediv>
|
||||
<refname>Pool::__destruct</refname>
|
||||
<refpurpose>Destroys the Pool</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>public</modifier> <type>void</type><methodname>Pool::__destruct</methodname>
|
||||
<void/>
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Shuts down all Workers, and collect all Stackables, finally destroys the Pool
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
void
|
||||
</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
|
||||
-->
|
149
reference/pthreads/pool/collect.xml
Normal file
149
reference/pthreads/pool/collect.xml
Normal file
|
@ -0,0 +1,149 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- $Revision: 329926 $ -->
|
||||
|
||||
<refentry xml:id="pool.collect" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<refnamediv>
|
||||
<refname>Pool::collect</refname>
|
||||
<refpurpose>Collect references to completed tasks</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>public</modifier> <type>void</type><methodname>Pool::collect</methodname>
|
||||
<methodparam><type>Callable</type><parameter>collector</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Allows the Pool to collect references determined to be garbage by the given collector
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><parameter>collector</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
A Callable collector
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
void
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<para>
|
||||
<example>
|
||||
<title>Creating Pools</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
class MyWork extends Stackable {
|
||||
public function __construct() {
|
||||
$this->complete = false;
|
||||
}
|
||||
|
||||
public function run() {
|
||||
printf(
|
||||
"Hello from %s in Thread #%lu\n",
|
||||
__CLASS__, $this->worker->getThreadId());
|
||||
$this->complete = true;
|
||||
}
|
||||
|
||||
public function isComplete() {
|
||||
return $this->complete;
|
||||
}
|
||||
|
||||
protected $complete;
|
||||
}
|
||||
|
||||
class MyWorker extends Worker {
|
||||
|
||||
public function __construct(Something $something) {
|
||||
$this->something = $something;
|
||||
}
|
||||
|
||||
public function run() {
|
||||
/** ... **/
|
||||
}
|
||||
}
|
||||
|
||||
$pool = new Pool(8, \MyWorker::class, [new Something()]);
|
||||
$pool->submit(new MyWork());
|
||||
|
||||
usleep(1000);
|
||||
|
||||
$pool->collect(function($work){
|
||||
return $work->isComplete();
|
||||
});
|
||||
var_dump($pool);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
Hello from MyWork in Thread #140222468777728
|
||||
object(Pool)#1 (6) {
|
||||
["size":protected]=>
|
||||
int(8)
|
||||
["class":protected]=>
|
||||
string(8) "MyWorker"
|
||||
["workers":protected]=>
|
||||
array(1) {
|
||||
[0]=>
|
||||
object(MyWorker)#4 (1) {
|
||||
["something"]=>
|
||||
object(Something)#5 (0) {
|
||||
}
|
||||
}
|
||||
}
|
||||
["work":protected]=>
|
||||
array(0) {
|
||||
}
|
||||
["ctor":protected]=>
|
||||
array(1) {
|
||||
[0]=>
|
||||
object(Something)#2 (0) {
|
||||
}
|
||||
}
|
||||
["last":protected]=>
|
||||
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
|
||||
-->
|
62
reference/pthreads/pool/resize.xml
Normal file
62
reference/pthreads/pool/resize.xml
Normal file
|
@ -0,0 +1,62 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- $Revision: 329926 $ -->
|
||||
|
||||
<refentry xml:id="pool.resize" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<refnamediv>
|
||||
<refname>Pool::resize</refname>
|
||||
<refpurpose>Resize the Pool</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>public</modifier> <type>void</type><methodname>Pool::resize</methodname>
|
||||
<methodparam><type>integer</type><parameter>size</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Resize the Pool
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><parameter>size</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
The maximum number of Workers this Pool can create
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
void
|
||||
</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
|
||||
-->
|
48
reference/pthreads/pool/shutdown.xml
Normal file
48
reference/pthreads/pool/shutdown.xml
Normal file
|
@ -0,0 +1,48 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- $Revision: 329926 $ -->
|
||||
|
||||
<refentry xml:id="pool.shutdown" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<refnamediv>
|
||||
<refname>Pool::shutdown</refname>
|
||||
<refpurpose>Shutdown all Workers</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>public</modifier> <type>void</type><methodname>Pool::shutdown</methodname>
|
||||
<void/>
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Shutdown the Workers in this Pool
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
void
|
||||
</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
|
||||
-->
|
139
reference/pthreads/pool/submit.xml
Normal file
139
reference/pthreads/pool/submit.xml
Normal file
|
@ -0,0 +1,139 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- $Revision: 329926 $ -->
|
||||
|
||||
<refentry xml:id="pool.submit" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<refnamediv>
|
||||
<refname>Pool::submit</refname>
|
||||
<refpurpose>Submits a Stackable for execution</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>public</modifier> <type>int</type><methodname>Pool::submit</methodname>
|
||||
<methodparam><type>Stackable</type><parameter>task</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Submit the task to the next Worker in the Pool
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><parameter>size</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
The task for execution
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
the length of the stack on the selected Worker
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<para>
|
||||
<example>
|
||||
<title>Submitting Tasks</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
class MyWork extends Stackable {
|
||||
|
||||
public function run() {
|
||||
/* ... */
|
||||
}
|
||||
}
|
||||
|
||||
class MyWorker extends Worker {
|
||||
|
||||
public function __construct(Something $something) {
|
||||
$this->something = $something;
|
||||
}
|
||||
|
||||
public function run() {
|
||||
/** ... **/
|
||||
}
|
||||
}
|
||||
|
||||
$pool = new Pool(8, \MyWorker::class, [new Something()]);
|
||||
$pool->submit(new MyWork());
|
||||
var_dump($pool);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
object(Pool)#1 (6) {
|
||||
["size":protected]=>
|
||||
int(8)
|
||||
["class":protected]=>
|
||||
string(8) "MyWorker"
|
||||
["workers":protected]=>
|
||||
array(1) {
|
||||
[0]=>
|
||||
object(MyWorker)#4 (1) {
|
||||
["something"]=>
|
||||
object(Something)#5 (0) {
|
||||
}
|
||||
}
|
||||
}
|
||||
["work":protected]=>
|
||||
array(1) {
|
||||
[0]=>
|
||||
object(MyWork)#3 (1) {
|
||||
["worker"]=>
|
||||
object(MyWorker)#5 (1) {
|
||||
["something"]=>
|
||||
object(Something)#6 (0) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
["ctor":protected]=>
|
||||
array(1) {
|
||||
[0]=>
|
||||
object(Something)#2 (0) {
|
||||
}
|
||||
}
|
||||
["last":protected]=>
|
||||
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
|
||||
-->
|
48
reference/pthreads/thread/kill.xml
Normal file
48
reference/pthreads/thread/kill.xml
Normal file
|
@ -0,0 +1,48 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- $Revision: 332046 $ -->
|
||||
|
||||
<refentry xml:id="thread.kill" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<refnamediv>
|
||||
<refname>Thread::kill</refname>
|
||||
<refpurpose>Execution</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>final</modifier> <modifier>public</modifier> <type>void</type><methodname>Thread::kill</methodname>
|
||||
<void />
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Kills the referenced thread, dangerously !
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
void
|
||||
</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
|
||||
-->
|
|
@ -27,6 +27,7 @@
|
|||
<function name='thread::pop' from='PECL pthreads >= 0.45'/>
|
||||
<function name='thread::merge' from='PECL pthreads >= 0.45'/>
|
||||
<function name='thread::chunk' from='PECL pthreads >= 0.45'/>
|
||||
<function name='thread::kill' from='PECL pthreads >= 0.46'/>
|
||||
|
||||
<function name='worker' from='PECL pthreads >= 0.36'/>
|
||||
<function name='worker::start' from='PECL pthreads >= 0.36'/>
|
||||
|
@ -43,6 +44,7 @@
|
|||
<function name='worker::pop' from='PECL pthreads >= 0.45'/>
|
||||
<function name='worker::merge' from='PECL pthreads >= 0.45'/>
|
||||
<function name='worker::chunk' from='PECL pthreads >= 0.45'/>
|
||||
<function name='worker::kill' from='PECL pthreads >= 0.46'/>
|
||||
|
||||
<function name='stackable' from='PECL pthreads >= 0.36'/>
|
||||
<function name='stackable::run' from='PECL pthreads >= 0.36'/>
|
||||
|
@ -100,4 +102,4 @@ End:
|
|||
vim600: syn=xml fen fdm=syntax fdl=2 si
|
||||
vim: et tw=78 syn=sgml
|
||||
vi: ts=1 sw=1
|
||||
-->
|
||||
-->
|
||||
|
|
53
reference/pthreads/worker/kill.xml
Normal file
53
reference/pthreads/worker/kill.xml
Normal file
|
@ -0,0 +1,53 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- $Revision: 328967 $ -->
|
||||
|
||||
<refentry xml:id="worker.kill" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<refnamediv>
|
||||
<refname>Worker::kill</refname>
|
||||
<refpurpose>Execution</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>final</modifier> <modifier>public</modifier> <type>void</type><methodname>Worker::kill</methodname>
|
||||
<void />
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Kills the referenced Worker, dangerously !
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
&no.function.parameters;
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
void
|
||||
</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
|
||||
-->
|
Loading…
Reference in a new issue