TickLoop thread

This commit is contained in:
Shoghi Cervantes Pueyo 2013-01-10 17:10:15 +01:00
parent d5d319fb7c
commit eebbc263b0
4 changed files with 58 additions and 7 deletions

View file

@ -0,0 +1,40 @@
<?php
/*
-
/ \
/ \
/ PocketMine \
/ MP \
|\ @shoghicp /|
|. \ / .|
| .. \ / .. |
| .. | .. |
| .. | .. |
\ | /
\ | /
\ | /
\ | /
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
*/
class TickLoop extends Thread{
var $stop = false, $lastTick = 0;
public function run(){
while($this->stop !== true){
$time = microtime(true);
if($this->lastTick <= ($time - 0.05)){
$this->lastTick = $time;
$this->wait();
}
}
exit(0);
}
}