PHP_Fork
[ class tree: PHP_Fork ] [ index: PHP_Fork ] [ all elements ]

File: simple_controller.php

Source Location: /PHP_Fork-0.3.2/examples/simple_controller.php

Classes:

executeThread
PHP_Fork class. Wrapper around the pcntl_fork() stuff with a API set like Java language.
controllerThread
PHP_Fork class. Wrapper around the pcntl_fork() stuff with a API set like Java language.

Page Details:

Includes:

require_once("PHP/Fork.php") [line 28]
PHP_Fork class usage examples ================================================================================== NOTE: In real world you surely want to keep each class into a separate file, then include() it into your application.

For this examples is more useful to keep all_code_into_one_file, so that each example shows a unique feature of the PHP_Fork framework. ================================================================================== simple_controller.php

This example shows how to attach a controller to started pseudo-threads Forked processes can sometime die or defunct for many reasons... Without a controller process that periodically check thread status we can not ensure that started threads are still alive into system Here we have n executeThreads and a controllerThread that check all them when the controller detect that a thread is died it try to respawn it.

ATTENTION: this example fails on Cygwin platform, probably due to some bugs into ipc implementations that prevent the shared memory to be totally released when a process die.

==================================================================================


CTRL_MAX_IDLE [line 34]

CTRL_MAX_IDLE = 3

[ Top ]



CTRL_POLLING_INTERVAL [line 37]

CTRL_POLLING_INTERVAL = 5

[ Top ]



NUM_THREAD [line 31]

NUM_THREAD = 2

[ Top ]



_getInputCLI [line 179]

void _getInputCLI( )

Functions used by the console


[ Top ]



_read [line 186]

void _read( )



[ Top ]



Documentation generated on Mon, 11 Mar 2019 15:41:28 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.