Location: PHPKode > scripts > Thread > thread/php_fork-api.html
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  <html xmlns="http://www.w3.org/1999/xhtml">
		<head>
			<!-- template designed by Marco Von Ballmoos -->
			<title>Docs For Class PHP_Fork</title>
			<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'/>
		<style>
a { color: #336699; text-decoration: none; }
a:hover { color: #6699CC; text-decoration: underline; }
a:active { color: #6699CC; text-decoration: underline; }

body, table { font-family: Georgia, Times New Roman, Times, serif; font-size: 10pt }
p, li { line-height: 140% }
a img { border: 0px; }
dd { margin-left: 0px; padding-left: 1em; }

/* Page layout/boxes */

.info-box {}
.info-box-title { margin: 1em 0em 0em 0em; padding: .25em; font-weight: normal; font-size: 14pt; border: 2px solid #999999; background-color: #CCCCFF }
.info-box-body { border: 1px solid #999999; padding: .5em; }
.nav-bar { font-size: 8pt; white-space: nowrap; text-align: right; padding: .2em; margin: 0em 0em 1em 0em; }

.oddrow { background-color: #F8F8F8; border: 1px solid #AAAAAA; padding: .5em; margin-bottom: 1em}
.evenrow { border: 1px solid #AAAAAA; padding: .5em; margin-bottom: 1em}

.page-body { max-width: 800px; margin: auto; }
.tree dl { margin: 0px }

/* Index formatting classes */

.index-item-body { margin-top: .5em; margin-bottom: .5em}
.index-item-description { margin-top: .25em }
.index-item-details { font-weight: normal; font-style: italic; font-size: 8pt }
.index-letter-section { background-color: #EEEEEE; border: 1px dotted #999999; padding: .5em; margin-bottom: 1em}
.index-letter-title { font-size: 12pt; font-weight: bold }
.index-letter-menu { text-align: center; margin: 1em }
.index-letter { font-size: 12pt }

/* Docbook classes */

.description {}
.short-description { font-weight: bold; color: #666666; }
.tags {	padding-left: 0em; margin-left: 3em; color: #666666; list-style-type: square; }
.parameters {	padding-left: 0em; margin-left: 3em; font-style: italic; list-style-type: square; }
.redefinitions { font-size: 8pt; padding-left: 0em; margin-left: 2em; }
.package {  }
.package-title { font-weight: bold; font-size: 14pt; border-bottom: 1px solid black }
.package-details { font-size: 85%; }
.sub-package { font-weight: bold; font-size: 120% }
.tutorial { border-width: thin; border-color: #0066ff }
.tutorial-nav-box { width: 100%; border: 1px solid #999999; background-color: #F8F8F8; }
.nav-button-disabled { color: #999999; }
.nav-button:active,
.nav-button:focus,
.nav-button:hover { background-color: #DDDDDD; outline: 1px solid #999999; text-decoration: none }
.folder-title { font-style: italic }

/* Generic formatting */

.field { font-weight: bold; }
.detail { font-size: 8pt; }
.notes { font-style: italic; font-size: 8pt; }
.separator { background-color: #999999; height: 2px; }
.warning {  color: #FF6600; }
.disabled { font-style: italic; color: #999999; }

/* Code elements */

.line-number {  }

.class-table { width: 100%; }
.class-table-header { border-bottom: 1px dotted #666666; text-align: left}
.class-name { color: #000000; font-weight: bold; }

.method-summary { padding-left: 1em; font-size: 8pt }
.method-header { }
.method-definition { margin-bottom: .3em }
.method-title { font-weight: bold; }
.method-name { font-weight: bold; }
.method-signature { font-size: 85%; color: #666666; margin: .5em 0em }
.method-result { font-style: italic; }

.var-summary { padding-left: 1em; font-size: 8pt; }
.var-header { }
.var-title { margin-bottom: .3em }
.var-type { font-style: italic; }
.var-name { font-weight: bold; }
.var-default {}
.var-description { font-weight: normal; color: #000000; }

.include-title {  }
.include-type { font-style: italic; }
.include-name { font-weight: bold; }

.const-title {  }
.const-name { font-weight: bold; }

/* Syntax highlighting */

.src-code {  border: 1px solid #336699; padding: 1em; background-color: #EEEEEE; }

.src-comm { color: green; }
.src-id {  }
.src-inc { color: #0000FF; }
.src-key { color: #0000FF; }
.src-num { color: #CC0000; }
.src-str { color: #66cccc; }
.src-sym { font-weight: bold; }
.src-var { }

.src-php { font-weight: bold; }

.src-doc { color: #009999 }
.src-doc-close-template { color: #0000FF }
.src-doc-coretag { color: #0099FF; font-weight: bold }
.src-doc-inlinetag { color: #0099FF }
.src-doc-internal { color: #6699cc }
.src-doc-tag { color: #0080CC }
.src-doc-template { color: #0000FF }
.src-doc-type { font-style: italic }
.src-doc-var { font-style: italic }

/* tutorial */

.authors {  }
.author { font-style: italic; font-weight: bold }
.author-blurb { margin: .5em 0em .5em 2em; font-size: 85%; font-weight: normal; font-style: normal }
.example { border: 1px dashed #999999; background-color: #EEEEEE; padding: .5em }
.listing { border: 1px dashed #999999; background-color: #EEEEEE; padding: .5em; white-space: nowrap }
.release-info { font-size: 85%; font-style: italic; margin: 1em 0em }
.ref-title-box {  }
.ref-title {  }
.ref-purpose { font-style: italic; color: #666666 }
.ref-synopsis {  }
.title { font-weight: bold; margin: 1em 0em 0em 0em; padding: .25em; border: 2px solid #999999; background-color: #CCCCFF  }
.cmd-synopsis { margin: 1em 0em }
.cmd-title { font-weight: bold }
.toc { margin-left: 2em; padding-left: 0em }

</style>
		</head>
		<body>
			<div class="page-body">
<h2 class="class-name">Class PHP_Fork</h2>

<a name="sec-description"></a>
<div class="info-box">
	<div class="info-box-title">Description</div>
	<div class="nav-bar">
					<span class="disabled">Description</span> |
															<a href="#sec-method-summary">Methods</a> (<a href="#sec-methods">details</a>)

			</div>
	<div class="info-box-body">
		<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">PHP_Fork class. Wrapper around the pcntl_fork() stuff  with a API set like Java language.</p>
<p class="description"><p>Practical usage is done by extending this class, and re-defining  the run() method.  Example:  <pre><code><pre><br />1     <span class="src-key">class</span> <span class="src-id">executeThread</span> <span class="src-key">extends</span> <a href="php_fork-api.html">PHP_Fork</a> <span class="src-sym">{</span><br />2             <span class="src-key">var</span> <span class="src-var">$counter</span>;<br />3     <br />4             <span class="src-key">function</span> <span class="src-id">executeThread</span><span class="src-sym">(</span><span class="src-var">$name</span><span class="src-sym">)</span><br />5             <span class="src-sym">{</span><br />6                 <span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-id">PHP_Fork</span><span class="src-sym">(</span><span class="src-var">$name</span><span class="src-sym">)</span>;<br />7                 <span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-var">counter</span> = <span class="src-num">0</span>;<br />8             <span class="src-sym">}</span><br />9     <br />10            <span class="src-key">function</span> <span class="src-id">run</span><span class="src-sym">(</span><span class="src-sym">)</span><br />11            <span class="src-sym">{</span><br />12                <span class="src-var">$i</span> = <span class="src-num">0</span>;<br />13                <span class="src-key">while</span> <span class="src-sym">(</span><span class="src-var">$i</span> &lt; <span class="src-num">10</span><span class="src-sym">)</span> <span class="src-sym">{</span><br />14                    print <a href="http://www.php.net/time">time</a><span class="src-sym">(</span><span class="src-sym">)</span> . <span class="src-str">&quot;-(&quot;</span> . <span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-id">getName</span><span class="src-sym">(</span><span class="src-sym">)</span> . <span class="src-str">&quot;)-&quot;</span> . <span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-var">counter</span>++ . <span class="src-str">&quot;\n&quot;</span>;<br />15                    <a href="http://www.php.net/sleep">sleep</a><span class="src-sym">(</span><span class="src-num">1</span><span class="src-sym">)</span>;<br />16                    <span class="src-var">$i</span>++;<br />17                <span class="src-sym">}</span><br />18            <span class="src-sym">}</span><br />19     <span class="src-sym">}</span></pre></code></pre></p><p>This way PHP developers can enclose logic into a class that extends  PHP_Fork, then execute the start() method that forks a child process.  Communications with the forked process is ensured by using a Shared Memory  Segment; by using a user-defined signal and this shared memory developers  can access to child process methods that returns a serializable variable.</p><p>The shared variable space can be accessed with the tho methods:</p><p><ul><li>void setVariable($name, $value)</li><li>mixed getVariable($name)</li></ul>  $name must be a valid PHP variable name;  $value must be a variable or a serializable object.  Resources (db connections, streams, etc.) cannot be serialized and so they're not correctly handled.</p><p>Requires PHP build with --enable-cli --with-pcntl --enable-shmop.<br />  Only runs on *NIX systems, because Windows lacks of the pcntl ext.</p></p>
	<ul class="tags">
				<li><span class="field">author:</span> Luca Mariano &lt;<a href="mailto:hide@address.com">mailto:hide@address.com</a>&gt;</li>
				<li><span class="field">version:</span> 1.1</li>
				<li><span class="field">example:</span> <a href="../__examplesource/exsource___cygwin_home_lmariano_PHP_Fork_examples_basic.php_6f6fdbf58a14b07d4b3c4970ca915334.html">a basic example, only two pseudo-threads that increment a counter simultaneously.</a></li>
				<li><span class="field">example:</span> <a href="../__examplesource/exsource_n_home_lmariano_PHP_Fork_examples_passing_vars.php_f741c85115905d0f01dff9a66e2d19e1.html">shows variable exchange between the parent process and started pseudo-threads.</a></li>
				<li><span class="field">example:</span> <a href="../__examplesource/exsource_e_lmariano_PHP_Fork_examples_simple_controller.php_c7267db5d20531e3a758e7d6bdacecba.html">shows how to attach a controller to started pseudo-threads.</a></li>
				<li><span class="field">example:</span> <a href="../__examplesource/exsource_n_home_lmariano_PHP_Fork_examples_exec_methods.php_e3a6c8b15669e47e72990c5df4fb8c2a.html">shows a workaround to execute methods into the child process.</a></li>
				<li><span class="field">example:</span> <a href="../__examplesource/exsource_e_lmariano_PHP_Fork_examples_action_dispatcher.php_4afe3d623b02c61d565f658e33ed1176.html">shows a multiprocess application scheme where all processes run a sleep() cycle, and a centralized dispatcher pass them the work.</a></li>
			</ul>
		<p class="notes">
			Located in <a class="field" href="_Fork_Fork_php.html">Program_Root/Fork.php</a> (line <span class="field">83</span>)
		</p>


		<pre></pre>

			</div>
</div>



	<a name="sec-method-summary"></a>
	<div class="info-box">
		<div class="info-box-title">Method Summary</span></div>
		<div class="nav-bar">
			<a href="#sec-description">Description</a> |
									<span class="disabled">Methods</span> (<a href="#sec-methods">details</a>)
		</div>
		<div class="info-box-body">
			<div class="method-summary">

				<div class="method-definition">
											<span class="method-result">bool</span>
										<a href="#PHP_Fork" title="details" class="method-name">PHP_Fork</a>
											(<span class="var-type">string</span>&nbsp;<span class="var-name">$name</span>, <span class="var-type">integer</span>&nbsp;<span class="var-name">$puid</span>, <span class="var-type">integer</span>&nbsp;<span class="var-name">$guid</span>, [<span class="var-type">integer</span>&nbsp;<span class="var-name">$umask</span> = <span class="var-default">-1</span>])
									</div>

				<div class="method-definition">
											<span class="method-result">integer</span>
										<a href="#getLastAlive" title="details" class="method-name">getLastAlive</a>
										()
									</div>

				<div class="method-definition">
											<span class="method-result">string</span>
										<a href="#getName" title="details" class="method-name">getName</a>
										()
									</div>

				<div class="method-definition">
											<span class="method-result">integer</span>
										<a href="#getPid" title="details" class="method-name">getPid</a>
										()
									</div>

				<div class="method-definition">
											<span class="method-result">mixed</span>
										<a href="#getVariable" title="details" class="method-name">getVariable</a>
											(<span class="var-type">mixed</span>&nbsp;<span class="var-name">$name</span>)
									</div>

				<div class="method-definition">
											<span class="method-result">boolean</span>
										<a href="#isRunning" title="details" class="method-name">isRunning</a>
										()
									</div>

				<div class="method-definition">
											<span class="method-result">void</span>
										<a href="#register_callback_func" title="details" class="method-name">register_callback_func</a>
											(<span class="var-type">$arglist</span>&nbsp;<span class="var-name">$arglist</span>, <span class="var-type">$methodname</span>&nbsp;<span class="var-name">$methodname</span>)
									</div>

				<div class="method-definition">
											<span class="method-result">void</span>
										<a href="#run" title="details" class="method-name">run</a>
										()
									</div>

				<div class="method-definition">
											<span class="method-result">void</span>
										<a href="#setAlive" title="details" class="method-name">setAlive</a>
										()
									</div>

				<div class="method-definition">
											<span class="method-result">void</span>
										<a href="#setName" title="details" class="method-name">setName</a>
											(<span class="var-type">$name</span>&nbsp;<span class="var-name">$name</span>)
									</div>

				<div class="method-definition">
											<span class="method-result">void</span>
										<a href="#setVariable" title="details" class="method-name">setVariable</a>
											(<span class="var-type">mixed</span>&nbsp;<span class="var-name">$name</span>, <span class="var-type">mixed</span>&nbsp;<span class="var-name">$value</span>)
									</div>

				<div class="method-definition">
											<span class="method-result">void</span>
										<a href="#start" title="details" class="method-name">start</a>
										()
									</div>

				<div class="method-definition">
											<span class="method-result">boolean</span>
										<a href="#stop" title="details" class="method-name">stop</a>
										()
									</div>
							</div>
		</div>
	</div>


	<a name="sec-methods"></a>
	<div class="info-box">
		<div class="info-box-title">Methods</div>
		<div class="nav-bar">
			<a href="#sec-description">Description</a> |
													<a href="#sec-method-summary">Methods</a> (<span class="disabled">details</span>)

		</div>
		<div class="info-box-body">
			<A NAME='method_detail'></A>
<a name="methodPHP_Fork" id="PHP_Fork"><!-- --></a>
<div class="evenrow">

	<div class="method-header">
		<span class="method-title">Constructor PHP_Fork</span> (line <span class="line-number">215</span>)
	</div>

	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">PHP_Fork::PHP_Fork()  Allocates a new pseudo-thread object and set its name to $name.</p>
<p class="description"><p>Optionally, set a PUID, a GUID and a UMASK for the child process.  This also initialize Shared Memory Segments for process communications.</p><p>Supposing that you've defined the executeThread class as above,  creating the pseudo-threads instances is very simple:</p><p><pre><code><pre><br />1     ...<br />2            <span class="src-var">$executeThread1</span> = <span class="src-key">new</span> <span class="src-id">executeThread</span> <span class="src-sym">(</span><span class="src-str">&quot;executeThread-1&quot;</span><span class="src-sym">)</span>;<br />3            <span class="src-var">$executeThread2</span> = <span class="src-key">new</span> <span class="src-id">executeThread</span> <span class="src-sym">(</span><span class="src-str">&quot;executeThread-2&quot;</span><span class="src-sym">)</span>;<br />4          ...</pre></code></pre>  The pseudo-thread name must be unique; you can create and start as many pseudo-threads as you want;  the limit is (of course) system resources.</p></p>
	<ul class="tags">
				<li><span class="field">return:</span> true if the Shared Memory Segments are OK, false otherwise.<br />Notice that only if shared mem is ok the process will be forked.</li>
				<li><span class="field">access:</span> public</li>
			</ul>

	<div class="method-signature">
		<span class="method-result">bool</span>
		<span class="method-name">
			PHP_Fork
		</span>
					(<span class="var-type">string</span>&nbsp;<span class="var-name">$name</span>, <span class="var-type">integer</span>&nbsp;<span class="var-name">$puid</span>, <span class="var-type">integer</span>&nbsp;<span class="var-name">$guid</span>, [<span class="var-type">integer</span>&nbsp;<span class="var-name">$umask</span> = <span class="var-default">-1</span>])
			</div>

			<ul class="parameters">
					<li>
				<span class="var-type">string</span>
				<span class="var-name">$name</span><span class="var-description">: The name of this pseudo-thread; must be unique between PHP processes running on the same server.</span>			</li>
					<li>
				<span class="var-type">integer</span>
				<span class="var-name">$puid</span><span class="var-description">: Owner of the forked process; if none, the user will be the same that created the pseudo-thread</span>			</li>
					<li>
				<span class="var-type">integer</span>
				<span class="var-name">$guid</span><span class="var-description">: Group of the forked process; if none, the group will be the same of the user that created the pseudo-thread</span>			</li>
					<li>
				<span class="var-type">integer</span>
				<span class="var-name">$umask</span><span class="var-description">: the umask of the new process; if none, the umask will be the same of the user  that created the pseudo-thread</span>			</li>
				</ul>


	</div>
<a name="methodgetLastAlive" id="getLastAlive"><!-- --></a>
<div class="oddrow">

	<div class="method-header">
		<span class="method-title">getLastAlive</span> (line <span class="line-number">311</span>)
	</div>

	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">PHP_Fork::getLastAlive()</p>
<p class="description"><p>Read the time elapsed since the last child setAlive() call.</p><p>This method is useful because often we have a pseudo-thread pool and we  need to know each pseudo-thread status.  if the child executes the setAlive() method, the parent with  getLastAlive() can know that child is alive.</p></p>
	<ul class="tags">
				<li><span class="field">return:</span> the elapsed seconds since the last child setAlive() call.</li>
				<li><span class="field">see:</span> <a href="php_fork-api.html#methodsetAlive">PHP_Fork::setAlive()</a></li>
			</ul>

	<div class="method-signature">
		<span class="method-result">integer</span>
		<span class="method-name">
			getLastAlive
		</span>
				()
			</div>



	</div>
<a name="methodgetName" id="getName"><!-- --></a>
<div class="evenrow">

	<div class="method-header">
		<span class="method-title">getName</span> (line <span class="line-number">328</span>)
	</div>

	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">PHP_Fork::getName()  Returns this pseudo-thread's name.</p>
	<ul class="tags">
				<li><span class="field">return:</span> the name of the pseudo-thread.</li>
				<li><span class="field">see:</span> <a href="php_fork-api.html#methodsetName">PHP_Fork::setName()</a></li>
			</ul>

	<div class="method-signature">
		<span class="method-result">string</span>
		<span class="method-name">
			getName
		</span>
				()
			</div>



	</div>
<a name="methodgetPid" id="getPid"><!-- --></a>
<div class="oddrow">

	<div class="method-header">
		<span class="method-title">getPid</span> (line <span class="line-number">340</span>)
	</div>

	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">PHP_Fork::getPid()  Return the PID of the current pseudo-thread.</p>
	<ul class="tags">
				<li><span class="field">return:</span> the PID.</li>
			</ul>

	<div class="method-signature">
		<span class="method-result">integer</span>
		<span class="method-name">
			getPid
		</span>
				()
			</div>



	</div>
<a name="methodgetVariable" id="getVariable"><!-- --></a>
<div class="evenrow">

	<div class="method-header">
		<span class="method-title">getVariable</span> (line <span class="line-number">275</span>)
	</div>

	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">PHP_Fork::getVariable()</p>
<p class="description"><p>Get a variable from the shared memory segment</p></p>
	<ul class="tags">
				<li><span class="field">return:</span> the requested variable (or NULL if it doesn't exists).</li>
				<li><span class="field">see:</span> <a href="php_fork-api.html#methodsetVariable">PHP_Fork::setVariable()</a></li>
			</ul>

	<div class="method-signature">
		<span class="method-result">mixed</span>
		<span class="method-name">
			getVariable
		</span>
					(<span class="var-type">mixed</span>&nbsp;<span class="var-name">$name</span>)
			</div>



	</div>
<a name="methodisRunning" id="isRunning"><!-- --></a>
<div class="oddrow">

	<div class="method-header">
		<span class="method-title">isRunning</span> (line <span class="line-number">245</span>)
	</div>

	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">PHP_Fork::isRunning()  Test if the pseudo-thread is already started.</p>
<p class="description"><p>A pseudo-thread that is instantiated but not started only exist as an instance of  PHP_Fork class into parent process; no forking is done until the start() method  is called.</p></p>
	<ul class="tags">
				<li><span class="field">return:</span> true is the child is already forked.</li>
			</ul>

	<div class="method-signature">
		<span class="method-result">boolean</span>
		<span class="method-name">
			isRunning
		</span>
				()
			</div>



	</div>
<a name="methodregister_callback_func" id="register_callback_func"><!-- --></a>
<div class="evenrow">

	<div class="method-header">
		<span class="method-title">register_callback_func</span> (line <span class="line-number">354</span>)
	</div>

	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">PHP_Fork::register_callback_func()</p>
<p class="description"><p>This is called from within the parent method; all the communication stuff is done here...</p></p>
	<ul class="tags">
				<li><span class="field">example:</span> <a href="../__examplesource/exsource_n_home_lmariano_PHP_Fork_examples_exec_methods.php_e3a6c8b15669e47e72990c5df4fb8c2a.html">example</a></li>
			</ul>

	<div class="method-signature">
		<span class="method-result">void</span>
		<span class="method-name">
			register_callback_func
		</span>
					(<span class="var-type">$arglist</span>&nbsp;<span class="var-name">$arglist</span>, <span class="var-type">$methodname</span>&nbsp;<span class="var-name">$methodname</span>)
			</div>

			<ul class="parameters">
					<li>
				<span class="var-type">$arglist</span>
				<span class="var-name">$arglist</span>			</li>
					<li>
				<span class="var-type">$methodname</span>
				<span class="var-name">$methodname</span>			</li>
				</ul>


	</div>
<a name="methodrun" id="run"><!-- --></a>
<div class="oddrow">

	<div class="method-header">
		<span class="method-title">run</span> (line <span class="line-number">417</span>)
	</div>

	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">PHP_Fork::run()</p>
<p class="description"><p>This method actually implements the pseudo-thread logic.<br />  Subclasses of PHP_Fork MUST override this method as v.0.2</p></p>
	<ul class="tags">
				<li><span class="field">abstract:</span> </li>
			</ul>

	<div class="method-signature">
		<span class="method-result">void</span>
		<span class="method-name">
			run
		</span>
				()
			</div>



	</div>
<a name="methodsetAlive" id="setAlive"><!-- --></a>
<div class="evenrow">

	<div class="method-header">
		<span class="method-title">setAlive</span> (line <span class="line-number">293</span>)
	</div>

	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">PHP_Fork::setAlive()</p>
<p class="description"><p>Set a pseudo-thread property that can be read from parent process  in order to know the child activity.</p><p>Practical usage requires that child process calls this method at regular  time intervals; parent will use the getLastAlive() method to know  the elapsed time since the last pseudo-thread life signals...</p></p>
	<ul class="tags">
				<li><span class="field">see:</span> <a href="php_fork-api.html#methodgetLastAlive">PHP_Fork::getLastAlive()</a></li>
			</ul>

	<div class="method-signature">
		<span class="method-result">void</span>
		<span class="method-name">
			setAlive
		</span>
				()
			</div>



	</div>
<a name="methodsetName" id="setName"><!-- --></a>
<div class="oddrow">

	<div class="method-header">
		<span class="method-title">setName</span> (line <span class="line-number">430</span>)
	</div>

	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">PHP_Fork::setName()  Changes the name of this thread to the given name.</p>
	<ul class="tags">
				<li><span class="field">see:</span> <a href="php_fork-api.html#methodgetName">PHP_Fork::getName()</a></li>
			</ul>

	<div class="method-signature">
		<span class="method-result">void</span>
		<span class="method-name">
			setName
		</span>
					(<span class="var-type">$name</span>&nbsp;<span class="var-name">$name</span>)
			</div>

			<ul class="parameters">
					<li>
				<span class="var-type">$name</span>
				<span class="var-name">$name</span>			</li>
				</ul>


	</div>
<a name="methodsetVariable" id="setVariable"><!-- --></a>
<div class="evenrow">

	<div class="method-header">
		<span class="method-title">setVariable</span> (line <span class="line-number">261</span>)
	</div>

	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">PHP_Fork::setVariable()</p>
<p class="description"><p>Set a variable into the shared memory segment so that it can accessed  both from the parent &amp; from the child process.</p></p>
	<ul class="tags">
				<li><span class="field">see:</span> <a href="php_fork-api.html#methodgetVariable">PHP_Fork::getVariable()</a></li>
			</ul>

	<div class="method-signature">
		<span class="method-result">void</span>
		<span class="method-name">
			setVariable
		</span>
					(<span class="var-type">mixed</span>&nbsp;<span class="var-name">$name</span>, <span class="var-type">mixed</span>&nbsp;<span class="var-name">$value</span>)
			</div>



	</div>
<a name="methodstart" id="start"><!-- --></a>
<div class="oddrow">

	<div class="method-header">
		<span class="method-title">start</span> (line <span class="line-number">451</span>)
	</div>

	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">PHP_Fork::start()  Causes this pseudo-thread to begin parallel execution.</p>
<p class="description"><p><pre><code><pre><br />1     ...<br />2            <span class="src-var">$executeThread1</span><span class="src-sym">-&gt;</span><a href="php_fork-api.html#methodstart">start</a><span class="src-sym">(</span><span class="src-sym">)</span>;<br />3          ...</pre></code></pre></p><p>This method check first of all the Shared Memory Segment; if ok, if forks  the child process, attach signal handler and returns immediatly.  The status is set to running, and a PID is assigned.  The result is that two pseudo-threads are running concurrently: the current thread (which returns from the call to the start() method) and the other thread (which executes its run() method).</p></p>

	<div class="method-signature">
		<span class="method-result">void</span>
		<span class="method-name">
			start
		</span>
				()
			</div>



	</div>
<a name="methodstop" id="stop"><!-- --></a>
<div class="evenrow">

	<div class="method-header">
		<span class="method-title">stop</span> (line <span class="line-number">501</span>)
	</div>

	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">PHP_Fork::stop()  Causes the current thread to die.</p>
<p class="description"><p><pre><code><pre><br />1     ...<br />2            <span class="src-var">$executeThread1</span><span class="src-sym">-&gt;</span><a href="php_fork-api.html#methodstop">stop</a><span class="src-sym">(</span><span class="src-sym">)</span>;<br />3          ...</pre></code></pre></p><p>The relative process is killed and disappears immediately from the processes list.</p></p>
	<ul class="tags">
				<li><span class="field">return:</span> true if the process is succesfully stopped, false otherwise.</li>
			</ul>

	<div class="method-signature">
		<span class="method-result">boolean</span>
		<span class="method-name">
			stop
		</span>
				()
			</div>



	</div>

		</div>
	</div>

	<p class="notes" id="credit">
		Documentation generated on Tue,  9 Dec 2003 10:46:02 +0100 by <a href="http://www.phpdoc.org" target="_blank">phpDocumentor 1.2.2</a>
	</p>
	</div></body>
</html>
Return current item: Thread