Yay generation uses async tasks

This commit is contained in:
Shoghi Cervantes
2015-03-26 18:21:39 +01:00
parent 668ddeeb13
commit 72c4c01542
18 changed files with 287 additions and 1124 deletions

View File

@ -30,6 +30,9 @@ use pocketmine\Server;
*/
abstract class AsyncTask extends \Collectable{
/** @var AsyncWorker $worker */
public $worker = null;
private $result = null;
private $serialized = false;
/** @var int */
@ -83,6 +86,32 @@ abstract class AsyncTask extends \Collectable{
return $this->taskId;
}
/**
* Gets something into the local thread store.
* You have to initialize this in some way from the task on run
*
* @param string $identifier
* @return mixed
*/
public function getFromThreadStore($identifier){
global $store;
return $this->isGarbage() ? null : $store[$identifier];
}
/**
* Saves something into the local thread store.
* This might get deleted at any moment.
*
* @param string $identifier
* @param mixed $value
*/
public function saveToThreadStore($identifier, $value){
global $store;
if(!$this->isGarbage()){
$store[$identifier] = $value;
}
}
/**
* Actions to execute when run
*