MediaWiki REL1_35
|
Reads lines of work from an input stream and farms them out to multiple child streams. More...
Public Member Functions | |
__construct ( $numProcs, $workCallback, $input, $output) | |
start () | |
Start the child processes.This should only be called from the command line. It should be called as early as possible during execution.This will return 'child' in the child processes. In the parent process, it will run until all the child processes exit or a TERM signal is received. It will then return 'done'.
| |
Public Member Functions inherited from ForkController | |
__construct ( $numProcs, $flags=0) | |
getChildNumber () | |
Get the number of the child currently running. | |
Protected Member Functions | |
consume () | |
Child worker process. | |
consumeNoFork () | |
Special cased version of self::consume() when no forking occurs. | |
feedChildren (array $sockets) | |
Reads lines of work from $this->input and farms them out to the provided socket. | |
forkWorkers ( $numProcs) | |
receive ( $id, $data) | |
updateAvailableSockets (&$sockets, &$used, $timeout) | |
Moves sockets from $used to $sockets when they are available for more work. | |
Protected Member Functions inherited from ForkController | |
handleTermSignal ( $signal) | |
initChild () | |
prepareEnvironment () | |
Protected Attributes | |
string[] | $delayedOutputData = [] |
Int key indicates order, value is data. | |
resource | $input |
int | $nextOutputId |
resource | $output |
callable | $workCallback |
Protected Attributes inherited from ForkController | |
$childNumber = 0 | |
$children = [] | |
$flags = 0 | |
$procsToStart = 0 | |
$termReceived = false | |
Additional Inherited Members | |
Static Protected Attributes inherited from ForkController | |
static | $restartableSignals |
Reads lines of work from an input stream and farms them out to multiple child streams.
Each child has exactly one piece of work in flight at a given moment. Writes the result of child's work to an output stream. If numProcs <= zero the work will be performed in process.
This class amends ForkController with the requirement that the output is produced in the same exact order as input values were.
Currently used by CirrusSearch extension to implement CLI search script.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. http://www.gnu.org/copyleft/gpl.html
Definition at line 32 of file OrderedStreamingForkController.php.
OrderedStreamingForkController::__construct | ( | $numProcs, | |
$workCallback, | |||
$input, | |||
$output | |||
) |
int | $numProcs | The number of worker processes to fork |
callable | $workCallback | A callback to call in the child process once for each line of work to process. |
resource | $input | A socket to read work lines from |
resource | $output | A socket to write the result of work to. |
Definition at line 51 of file OrderedStreamingForkController.php.
References $input, $output, and $workCallback.
|
protected |
Child worker process.
Reads work from $this->input and writes the result of that work to $this->output when completed.
Definition at line 117 of file OrderedStreamingForkController.php.
References $line.
Referenced by start().
|
protected |
Special cased version of self::consume() when no forking occurs.
Definition at line 131 of file OrderedStreamingForkController.php.
Referenced by start().
|
protected |
Reads lines of work from $this->input and farms them out to the provided socket.
resource[] | $sockets |
Definition at line 153 of file OrderedStreamingForkController.php.
References updateAvailableSockets().
Referenced by forkWorkers().
|
protected |
int | $numProcs |
Reimplemented from ForkController.
Definition at line 78 of file OrderedStreamingForkController.php.
References feedChildren(), ForkController\initChild(), and ForkController\prepareEnvironment().
|
protected |
int | $id | |
string | $data |
Definition at line 209 of file OrderedStreamingForkController.php.
Referenced by updateAvailableSockets().
OrderedStreamingForkController::start | ( | ) |
Start the child processes.This should only be called from the command line. It should be called as early as possible during execution.This will return 'child' in the child processes. In the parent process, it will run until all the child processes exit or a TERM signal is received. It will then return 'done'.
Reimplemented from ForkController.
Definition at line 61 of file OrderedStreamingForkController.php.
References consume(), and consumeNoFork().
|
protected |
Moves sockets from $used to $sockets when they are available for more work.
resource[] | &$sockets | List of sockets that are waiting for work |
resource[] | &$used | List of sockets currently performing work |
int | $timeout | The number of seconds to block waiting. 0 for non-blocking operation. |
Definition at line 191 of file OrderedStreamingForkController.php.
References $line, and receive().
Referenced by feedChildren().
|
protected |
Int key indicates order, value is data.
Definition at line 42 of file OrderedStreamingForkController.php.
|
protected |
Definition at line 36 of file OrderedStreamingForkController.php.
Referenced by __construct().
|
protected |
Definition at line 40 of file OrderedStreamingForkController.php.
|
protected |
Definition at line 38 of file OrderedStreamingForkController.php.
Referenced by __construct().
|
protected |
Definition at line 34 of file OrderedStreamingForkController.php.
Referenced by __construct().