mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-07 10:22:56 +00:00
Yay generation uses async tasks
This commit is contained in:
@ -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
|
||||
*
|
||||
|
Reference in New Issue
Block a user