Created
July 26, 2008 14:34
-
-
Save twxxk/2659 to your computer and use it in GitHub Desktop.
tickを使った非同期実行の単純なサンプル
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* 非同期実行の意味なしサンプル | |
*/ | |
class A { | |
private $name; | |
public function __construct($name){ | |
$this->name = $name; | |
} | |
/** | |
* 一回分の処理を実行する | |
*/ | |
public function process(){ | |
echo 'Hello from ', $this->name, "\n"; | |
} | |
} | |
$a = new A('a'); | |
$b = new A('b'); | |
register_tick_function(array($a, 'process')); | |
declare(ticks=10) { | |
for($i = 0; $i < 10; ++$i){ | |
$b->process(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment