php-doc-en/reference/pthreads/modifiers.xml
2017-04-27 15:39:41 +00:00

90 lines
2.1 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>
<warning>
<para>
These semantics are only applicable to pthreads v2 - they have been removed in pthreads v3.
</para>
</warning>
<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 Threaded 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 Threaded object 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
-->