twxxk (owner)

Revisions

gist: 2659 Download_button fork
public
Description:
tickを使った非同期実行の単純なサンプル
Public Clone URL: git://gist.github.com/2659.git
Embed All Files: show embed
PHP #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?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();
}
}