PHP Classes

File: example/Basic/run

Recommend this page to a friend!
  Classes of nvb   Process Fork Manager for PHP   example/Basic/run   Download  
File: example/Basic/run
Role: Example script
Content type: text/plain
Description: Example script
Class: Process Fork Manager for PHP
Run parallel processes and manage their execution
Author: By
Last change:
Date: 6 years ago
Size: 797 bytes
 

Contents

Class file image Download
#!/usr/bin/env php
<?php
/**
 * @author stev leibelt <artodeto@bazzline.net>
 * @since 2014-07-20
 */

namespace Net\Bazzline\Component\ProcessForkManager\Example\Basic;

require_once
__DIR__ . '/../bootstrap.php';
require_once
'ExampleTask.php';

use
Net\Bazzline\Component\ProcessForkManager\ForkManagerFactory;

$factory = new ForkManagerFactory();
$manager = $factory->create();
$totalNumberOfTasks = 7;

for (
$iterator = 0; $iterator < $totalNumberOfTasks; ++$iterator) {
   
$task = new ExampleTask();
   
$manager->addTask($task);
}

$manager->getTimeLimitManager()->setBufferInSeconds(2);
$manager->getTimeLimitManager()->setLimitInSeconds(20);

$manager->getMemoryLimitManager()->setBufferInMegaBytes(2);
$manager->getMemoryLimitManager()->setLimitInMegaBytes(64);

$manager->execute();