The Stackable class

(No version information available, might only be in SVN)

Wstęp

Stackables are tasks that are executed by Worker threads. You can synchronize with, read, and write Stackable objects before, after and during their execution.

Krótki opis klasy

Stackable {
/* Metody */
final public boolean isRunning ( void )
final public boolean isWaiting ( void )
final public boolean notify ( void )
abstract public void run ( void )
final public boolean wait ([ string $timeout ] )
}

Spis treści

add a note add a note

User Contributed Notes 1 note

up
0
lein_urg at 163 dot com
9 months ago
How to give worker a class instance which has a resoure, such as database access class?

I found a way of that:
you just need to modify you class to extends Stackable, then add a empty run method, then modify all private methods to public method.

Example:
<?php
//old one
class db {
    private
$conn=NULL;
    public function
db($user,$pwd='',$db_name,$host='localhost',$_charset='utf8',$connectImediatly = false){   
       
$this->doConnect();
    }
   
    private function
doConnect($flag=false)
    {   
       
$this->conn = @mysql_connect($host,$user,$pwd,1) or die('A'.mysql_error());
       
$this->doselect($db_name,$this->charset);
    }
}

===>

<?
php
//new one , $db=new $db(...); $worker = new myworker($db);
//$db will work well in your worker
class db extends Stackable{
    private
$conn=NULL;
    public function
db($user,$pwd='',$db_name,$host='localhost',$_charset='utf8',$connectImediatly = false){   
       
$this->doConnect();
    }
   
    public function
doConnect($flag=false)
    {   
       
$this->conn = @mysql_connect($host,$user,$pwd,1) or die('A'.mysql_error());
       
$this->doselect($db_name,$this->charset);
    }
   
    public function
run(){
       
    }
}
To Top