[prev in list] [next in list] [prev in thread] [next in thread]
List: php-doc-cvs
Subject: [DOC-CVS] =?utf-8?q?svn:_/phpdoc/en/trunk/reference/pthreads/_examples.xml?=
From: Joe_Watkins <krakjoe () php ! net>
Date: 2012-09-26 17:19:20
Message-ID: svn-krakjoe-1348679960-327810-254550438 () svn ! php ! net
[Download RAW message or body]
krakjoe Wed, 26 Sep 2012 17:19:20 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=327810
Log:
tidy examples page
Changed paths:
U phpdoc/en/trunk/reference/pthreads/examples.xml
Modified: phpdoc/en/trunk/reference/pthreads/examples.xml
===================================================================
--- phpdoc/en/trunk/reference/pthreads/examples.xml 2012-09-26 17:04:30 UTC (rev \
327809)
+++ phpdoc/en/trunk/reference/pthreads/examples.xml 2012-09-26 17:19:20 UTC (rev \
327810) @@ -5,10 +5,10 @@
&reftitle.examples;
<section role="examples">
+ <para>This HelloWorld example demonstrates how simple it is to define and execute \
Threads in PHP applications.</para> <example>
<title>Hello World Example</title>
- <para>This HelloWorld example demonstrates how simple it is to define and execute \
Threads in PHP applications.</para>
- <screen>
+ <programlisting role="php">
<![CDATA[
<?php
class HelloWorld extends Thread {
@@ -28,13 +28,11 @@
}
?>
]]>
- </screen>
+ </programlisting>
</example>
</section>
<section role="examples">
- <example>
- <title>Synchronization</title>
<para>
The purpose of PHP is to generate content, having Threading in the toolbox
makes more content available. But content is a relative subject, for this
@@ -96,7 +94,9 @@
to execute, or forced to wait, to allow flexible, powerful multi-threading
whether being used for a Search Engine or Administration ( ie. cron jobs ).
</para>
- <screen>
+ <example>
+ <title>Synchronization</title>
+ <programlisting role="php">
<![CDATA[
<?php
class Task1 extends Thread {
@@ -144,18 +144,16 @@
/* ... */
?>
]]>
- </screen>
+ </programlisting>
+ </example>
<para>
Using the wait/notify mechanism included in pthreads hides the complexity of
using Mutex and Condition Variables to synchronize Threads, greatly simplifies
readability and more importantly maintainability of an idea or implementation.
</para>
- </example>
</section>
<section role="examples">
- <example>
- <title>Mutex and Condition Variables</title>
<para>
pthreads allows direct access to ( a subset of ) both of these features.
The programmer should take care to destroy Mutex and Condition Variable
@@ -171,7 +169,9 @@
Mutex and Condition Variables persist once allocated until they are explicitly
destroyed.
</para>
- <screen>
+ <example>
+ <title>Mutex and Condition Variables</title>
+ <programlisting role="php">
<![CDATA[
<?php
/* ... */
@@ -181,7 +181,8 @@
}
?>
]]>
- </screen>
+ </programlisting>
+ </example>
<para>
The snippet above shows a PHP script sending it's final broadcast to the Threads
it has created and cleaning up the Condition Variable it created and used for
@@ -189,6 +190,7 @@
using $signals - waiting for a signal always requires a Mutex - and as the
Condition Variable is no longer valid, the accompanying Mutex is also destroyed.
</para>
+ <para>
<warning>
<para>
Before the programmer attempts to use Condition Variables they should have
@@ -207,11 +209,10 @@
risk of Spurious Wakeups.
</para>
</warning>
- </example>
+ </para>
</section>
<section role="examples">
- <example>
<title>Thread Members</title>
<para>
The members of a Thread can be of any type that PHP supports the serialization
@@ -227,7 +228,8 @@
before the newly created context executes Thread::run. This results in correct
deserialization of the programmer declared type in the new context.
</para>
- <screen>
+ <example>
+ <programlisting role="php">
<![CDATA[
<?php
class ExampleThread extends Thread {
@@ -258,7 +260,8 @@
}
?>
]]>
- </screen>
+ </programlisting>
+ </example>
<para>
In the example above, /path/to/inc.php declares a class, as defined by the
programmer. The programmer includes the declaration in the global scope
@@ -266,7 +269,6 @@
The instance of ExampleThread is able to manipulate the object and execute
member functions having included the declaration using __prepare magic.
</para>
- </example>
</section>
</chapter>
--
PHP Documentation Commits Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic