PopulationTask
        
        extends AsyncTask
    
    
            
            in package
            
        
    
    
    
        
            Class used to run async tasks in other threads.
Tags
Table of Contents
- TLS_KEY_ON_COMPLETION = "onCompletion"
- $progressUpdates : Threaded
- $worker : AsyncWorker|null
- $adjacentChunks : string
- $cancelRun : bool
- $chunk : string|null
- $chunkX : int
- $chunkZ : int
- $crashed : bool
- $finished : bool
- $result : scalar|null
- $serialized : bool
- $submitted : bool
- $threadLocalStorage : ArrayObject|array<string|int, mixed>|null
- $worldId : int
- __construct() : mixed
- __destruct() : mixed
- cancelRun() : void
- getResult() : mixed
- hasCancelledRun() : bool
- hasResult() : bool
- isCrashed() : bool
- isFinished() : bool
- Returns whether this task has finished executing, whether successfully or not. This differs from isRunning() because it is not true prior to task execution.
- isSubmitted() : bool
- onCompletion() : void
- Actions to execute when completed (on main thread) Implement this if you want to handle the data in your AsyncTask after it has been processed
- onError() : void
- Called from the main thread when the async task experiences an error during onRun(). Use this for things like promise rejection.
- onProgressUpdate() : void
- Called from the main thread after {@link AsyncTask::publishProgress} is called.
- onRun() : void
- Actions to execute when run
- publishProgress() : void
- Call this method from {@link AsyncTask::onRun} (AsyncTask execution thread) to schedule a call to {@link AsyncTask::onProgressUpdate} from the main thread with the given progress parameter.
- run() : void
- setResult() : void
- setSubmitted() : void
- fetchLocal() : mixed
- Retrieves data stored in thread-local storage.
- reallyDestruct() : void
- Override this to do normal __destruct() cleanup from a child class.
- storeLocal() : void
- Saves mixed data in thread-local storage. Data stored using this storage is **only accessible from the thread it was stored on**. Data stored using this method will **not** be serialized.
- setOrGenerateChunk() : Chunk
Constants
TLS_KEY_ON_COMPLETION
    private
        mixed
    TLS_KEY_ON_COMPLETION
    = "onCompletion"
        
        
    
Properties
$progressUpdates
    public
        Threaded
    $progressUpdates
    
    
    
    
$worker
    public
        AsyncWorker|null
    $worker
     = null
    
    
    
$adjacentChunks
    private
        string
    $adjacentChunks
    
        
        
    
$cancelRun
    private
        bool
    $cancelRun
     = false
    
    
    
$chunk
    private
        string|null
    $chunk
    
        
        
    
$chunkX
    private
        int
    $chunkX
    
        
        
    
$chunkZ
    private
        int
    $chunkZ
    
        
        
    
$crashed
    private
        bool
    $crashed
     = false
    
    
    
$finished
    private
        bool
    $finished
     = false
    
    
    
$result
    private
        scalar|null
    $result
     = null
    
    
    
$serialized
    private
        bool
    $serialized
     = false
    
    
    
$submitted
    private
        bool
    $submitted
     = false
    
    
    
$threadLocalStorage
    private
    static    ArrayObject|array<string|int, mixed>|null
    $threadLocalStorage
     = null
    
        object hash => mixed data
Tags
$worldId
    private
        int
    $worldId
    
        
        
    
Methods
__construct()
    public
                    __construct(int $worldId, int $chunkX, int $chunkZ, Chunk|null $chunk, array<string|int, Chunk>|array<string|int, null> $adjacentChunks, Closure $onCompletion) : mixed
    
        Parameters
- $worldId : int
- $chunkX : int
- $chunkZ : int
- $chunk : Chunk|null
- $adjacentChunks : array<string|int, Chunk>|array<string|int, null>
- $onCompletion : Closure
Tags
Return values
mixed —__destruct()
    public
        final            __destruct() : mixed
        
    
    
        Return values
mixed —cancelRun()
    public
                    cancelRun() : void
        
    
    
        Return values
void —getResult()
    public
                    getResult() : mixed
    
    
    
        Return values
mixed —hasCancelledRun()
    public
                    hasCancelledRun() : bool
        
    
    
        Return values
bool —hasResult()
    public
                    hasResult() : bool
        
    
    
        Return values
bool —isCrashed()
    public
                    isCrashed() : bool
        
    
    
        Return values
bool —isFinished()
Returns whether this task has finished executing, whether successfully or not. This differs from isRunning() because it is not true prior to task execution.
    public
                    isFinished() : bool
    
    
    
        Return values
bool —isSubmitted()
    public
                    isSubmitted() : bool
        
    
    
        Return values
bool —onCompletion()
Actions to execute when completed (on main thread) Implement this if you want to handle the data in your AsyncTask after it has been processed
    public
                    onCompletion() : void
    
    
    
        Return values
void —onError()
Called from the main thread when the async task experiences an error during onRun(). Use this for things like promise rejection.
    public
                    onError() : void
    
    
    
        Return values
void —onProgressUpdate()
Called from the main thread after {@link AsyncTask::publishProgress} is called.
    public
                    onProgressUpdate(mixed $progress) : void
        Parameters
- $progress : mixed
- 
                    The parameter passed to . It is serialize()'ed and then unserialize()'ed, as if it has been cloned. 
Return values
void —onRun()
Actions to execute when run
    public
                    onRun() : void
    
    
    
        Return values
void —publishProgress()
Call this method from {@link AsyncTask::onRun} (AsyncTask execution thread) to schedule a call to {@link AsyncTask::onProgressUpdate} from the main thread with the given progress parameter.
    public
                    publishProgress(mixed $progress) : void
    
        Parameters
- $progress : mixed
- 
                    A value that can be safely serialize()'ed. 
Return values
void —run()
    public
                    run() : void
        
    
    
        Return values
void —setResult()
    public
                    setResult(mixed $result) : void
    
        Parameters
- $result : mixed
Return values
void —setSubmitted()
    public
                    setSubmitted() : void
        
    
    
        Return values
void —fetchLocal()
Retrieves data stored in thread-local storage.
    protected
                    fetchLocal(string $key) : mixed
        If you used storeLocal(), you can use this on the same thread to fetch data stored. This should be used during onProgressUpdate() and onCompletion() to fetch thread-local data stored on the parent thread.
Parameters
- $key : string
Tags
Return values
mixed —reallyDestruct()
Override this to do normal __destruct() cleanup from a child class.
    protected
                    reallyDestruct() : void
    
    
    
        Return values
void —storeLocal()
Saves mixed data in thread-local storage. Data stored using this storage is **only accessible from the thread it was stored on**. Data stored using this method will **not** be serialized.
    protected
                    storeLocal(string $key, mixed $complexData) : void
        This can be used to store references to variables which you need later on on the same thread, but not others.
For example, plugin references could be stored in the constructor of the async task (which is called on the main thread) using this, and then fetched in onCompletion() (which is also called on the main thread), without them becoming serialized.
Scalar types can be stored directly in class properties instead of using this storage.
Objects stored in this storage can be retrieved using fetchLocal() on the same thread that this method was called from.
Parameters
- $key : string
- $complexData : mixed
- 
                    the data to store 
Return values
void —setOrGenerateChunk()
    private
            static        setOrGenerateChunk(SimpleChunkManager $manager, Generator $generator, int $chunkX, int $chunkZ, Chunk|null $chunk) : Chunk
        
        Parameters
- $manager : SimpleChunkManager
- $generator : Generator
- $chunkX : int
- $chunkZ : int
- $chunk : Chunk|null