Login   Register  
PHP Classes
elePHPant
Icontem

File: taskmanager/container.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Sildaekar Decrura  >  PTM  >  taskmanager/container.php  >  Download  
File: taskmanager/container.php
Role: Auxiliary script
Content type: text/plain
Description: Container
Class: PTM
Manage PHP tasks running in parallel processes
Author: By
Last change: Fixed error reporting
Date: 2012-07-27 10:38
Size: 706 bytes
 

Contents

Class file image Download
<?php
/**
 * get_tasks()
 * * Grabs all tasks in the "tasks" directory and loads them into memory *
 * @return
 */
error_reporting(0);
function 
get_tasks($cwd){
    
$tasks=array();
    
$err=array();
    if (
$h opendir($cwd)) {
        while (
false !== ($file readdir($h))) {
            if(
$file!="."&&$file!=".."){
                
$tasks[]=$file;
            }
        }
        
closedir($h);
        return 
$tasks;
    }else{
        
$err[]=FALSE;
        
$err[]="Error opening tasks directory!";
        return 
$err;
    }
}

$cwd=getcwd();
$cwd=$cwd."/taskmanager/tasks";
$r=get_tasks($cwd);
if(
$r[0]==FALSE){
    echo 
$r[1];
}else{
    include(
"manager.task.php");
    include(
"worker.task.php");
    foreach(
$r as $task){
        include(
$cwd."/".$task);
    }
}
?>