Skip to content

Instantly share code, notes, and snippets.

@twxxk
Created July 26, 2008 14:34
Show Gist options
  • Save twxxk/2659 to your computer and use it in GitHub Desktop.
Save twxxk/2659 to your computer and use it in GitHub Desktop.
tickを使った非同期実行の単純なサンプル
<?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