1
0
mirror of https://github.com/php/doc-zh.git synced 2026-03-24 15:12:20 +01:00
Files
archived-doc-zh/reference/pthreads/worker.xml

107 lines
3.1 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: bf92d8bd839301de7c837d20ab1dac6c14f83bbf Maintainer: yuanyuqiang Status: ready -->
<!-- Reviewed: no -->
<reference xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude" xml:id="class.worker" role="class">
<title>Worker 类</title>
<titleabbrev>Worker</titleabbrev>
<partintro>
<!-- {{{ Worker intro -->
<section xml:id="worker.intro">
&reftitle.intro;
<simpara>
Worker 是一个具有持久化上下文的线程对象,通常用来在多个线程中使用。
</simpara>
<simpara>
当一个 Worker 对象开始之后,会执行它的 run 方法,但是即使 run 方法执行完毕,线程本身也不会消亡,除非遇到以下情况:
</simpara>
<itemizedlist>
<listitem>
<simpara>Worker 对象超出作用范围(没有指向它的引用了)</simpara>
</listitem>
<listitem>
<simpara>代码调用了 Worker 对象的 shutdown 方法</simpara>
</listitem>
<listitem>
<simpara>整个脚本终止了</simpara>
</listitem>
</itemizedlist>
<simpara>
这意味着程序员可以在程序执行过程中重用这个线程上下文:
在 Worker 对象的栈中添加对象会激活 Worker 对象执行被加入对象的 run 方法。
</simpara>
</section>
<!-- }}} -->
<section xml:id="worker.synopsis">
&reftitle.classsynopsis;
<!-- {{{ Synopsis -->
<classsynopsis>
<ooclass><classname>Worker</classname></ooclass>
<!-- {{{ Class synopsis -->
<classsynopsisinfo>
<ooclass>
<classname>Worker</classname>
</ooclass>
<ooclass>
<modifier>extends</modifier>
<classname>Thread</classname>
</ooclass>
<oointerface>
<interfacename>Traversable</interfacename>
</oointerface>
<oointerface>
<interfacename>Countable</interfacename>
</oointerface>
<oointerface>
<interfacename>ArrayAccess</interfacename>
</oointerface>
</classsynopsisinfo>
<!-- }}} -->
<classsynopsisinfo role="comment">&Methods;</classsynopsisinfo>
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.worker')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[not(@role='procedural')])"/>
<classsynopsisinfo role="comment">&InheritedMethods;</classsynopsisinfo>
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.thread')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[not(@role='procedural')])"/>
</classsynopsis>
<!-- }}} -->
</section>
</partintro>
&reference.pthreads.entities.worker;
</reference>
<!-- 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
-->