php-doc-en/reference/pthreads/modifiers.xml
Joe Watkins 81a2e5c190 correction
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@329984 c90b9560-bf6c-de11-be94-00142212c4b1
2013-04-03 05:57:27 +00:00

85 lines
2 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<chapter xml:id="pthreads.modifiers" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>Method Modifiers</title>
<titleabbrev>Modifiers</titleabbrev>
<para>
pthreads overrides the functionality of the protected and private method modifiers in order to provide functionality more suited to multi-threaded objects.
pthreads applies this functionality to all Thread, Worker and Stackable objects from creation.
</para>
<example>
<title>protected method example: protected methods can only be executed by one Thread at a time.</title>
<programlisting role="php">
<![CDATA[
<?php
class ExampleThread extends Thread {
public function run() {
/* thread code */
if ($this->synchronized()) {
}
}
protected function exclusive() {
/* synchronized method */
}
}
$thread = new ExampleThread();
if ($thread->start()) {
$thread->exclusive();
}
?>
]]>
</programlisting>
</example>
<example>
<title>private method example: private methods may only be executed by the Thread, Worker, or Stackable during execution</title>
<programlisting role="php">
<![CDATA[
<?php
class ExampleThread extends Thread {
public function run() {
/* thread code */
if ($this->insideonly()) {
}
}
private function insideonly() {
/* private method */
}
}
$thread = new ExampleThread();
if ($thread->start()) {
$thread->insideonly();
}
?>
]]>
</programlisting>
</example>
</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
-->