mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-21 08:17:34 +00:00
AsyncTask: fixing docs
This commit is contained in:
parent
99f65f19ac
commit
d55889d85f
@ -34,12 +34,12 @@ use function unserialize;
|
||||
*
|
||||
* An AsyncTask does not have its own thread. It is queued into an AsyncPool and executed if there is an async worker
|
||||
* with no AsyncTask running. Therefore, an AsyncTask SHOULD NOT execute for more than a few seconds. For tasks that
|
||||
* run for a long time or infinitely, start another {@link \pocketmine\Thread} instead.
|
||||
* run for a long time or infinitely, start another thread instead.
|
||||
*
|
||||
* WARNING: Any non-Threaded objects WILL BE SERIALIZED when assigned to members of AsyncTasks or other Threaded object.
|
||||
* If later accessed from said Threaded object, you will be operating on a COPY OF THE OBJECT, NOT THE ORIGINAL OBJECT.
|
||||
* If you want to store non-serializable objects to access when the task completes, store them using
|
||||
* {@link AsyncTask#storeLocal}.
|
||||
* {@link AsyncTask::storeLocal}.
|
||||
*
|
||||
* WARNING: As of pthreads v3.1.6, arrays are converted to Volatile objects when assigned as members of Threaded objects.
|
||||
* Keep this in mind when using arrays stored as members of your AsyncTask.
|
||||
@ -185,8 +185,8 @@ abstract class AsyncTask extends Collectable{
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* 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.
|
||||
*
|
||||
* @param mixed $progress A value that can be safely serialize()'ed.
|
||||
*/
|
||||
@ -207,12 +207,12 @@ abstract class AsyncTask extends Collectable{
|
||||
}
|
||||
|
||||
/**
|
||||
* Called from the main thread after {@link AsyncTask#publishProgress} is called.
|
||||
* All {@link AsyncTask#publishProgress} calls should result in {@link AsyncTask#onProgressUpdate} calls before
|
||||
* {@link AsyncTask#onCompletion} is called.
|
||||
* Called from the main thread after {@link AsyncTask::publishProgress} is called.
|
||||
* All {@link AsyncTask::publishProgress} calls should result in {@link AsyncTask::onProgressUpdate} calls before
|
||||
* {@link AsyncTask::onCompletion} is called.
|
||||
*
|
||||
* @param Server $server
|
||||
* @param mixed $progress The parameter passed to {@link AsyncTask#publishProgress}. It is serialize()'ed
|
||||
* @param mixed $progress The parameter passed to {@link AsyncTask::publishProgress}. It is serialize()'ed
|
||||
* and then unserialize()'ed, as if it has been cloned.
|
||||
*/
|
||||
public function onProgressUpdate(Server $server, $progress){
|
||||
@ -221,20 +221,20 @@ abstract class AsyncTask extends Collectable{
|
||||
|
||||
/**
|
||||
* Saves mixed data in thread-local storage on the parent thread. You may use this to retain references to objects
|
||||
* or arrays which you need to access in {@link AsyncTask#onCompletion} which cannot be stored as a property of
|
||||
* or arrays which you need to access in {@link AsyncTask::onCompletion} which cannot be stored as a property of
|
||||
* your task (due to them becoming serialized).
|
||||
*
|
||||
* Scalar types can be stored directly in class properties instead of using this storage.
|
||||
*
|
||||
* Objects stored in this storage MUST be retrieved through {@link #fetchLocal} when {@link #onCompletion} is called.
|
||||
* Objects stored in this storage MUST be retrieved through {@link AsyncTask::fetchLocal} when {@link AsyncTask::onCompletion} is called.
|
||||
* Otherwise, a NOTICE level message will be raised and the reference will be removed after onCompletion exits.
|
||||
*
|
||||
* WARNING: Use this method carefully. It might take a long time before an AsyncTask is completed. PocketMine will
|
||||
* keep a strong reference to objects passed in this method. This may result in a light memory leak. Usually this
|
||||
* does not cause memory failure, but be aware that the object may be no longer usable when the AsyncTask completes.
|
||||
* (E.g. a {@link \pocketmine\Level} object is no longer usable because it is unloaded while the AsyncTask is
|
||||
* executing, or even a plugin might be unloaded). Since PocketMine keeps a strong reference, the objects are still
|
||||
* valid, but the implementation is responsible for checking whether these objects are still usable.
|
||||
* (E.g. a Level object is no longer usable because it is unloaded while the AsyncTask is executing, or even a
|
||||
* plugin might be unloaded). Since PocketMine keeps a strong reference, the objects are still valid, but the
|
||||
* implementation is responsible for checking whether these objects are still usable.
|
||||
*
|
||||
* WARNING: THIS METHOD SHOULD ONLY BE CALLED FROM THE MAIN THREAD!
|
||||
*
|
||||
@ -259,13 +259,13 @@ abstract class AsyncTask extends Collectable{
|
||||
|
||||
/**
|
||||
* Returns and removes mixed data in thread-local storage on the parent thread. Call this method from
|
||||
* {@link AsyncTask#onCompletion} to fetch the data stored in the object store, if any.
|
||||
* {@link AsyncTask::onCompletion} to fetch the data stored in the object store, if any.
|
||||
*
|
||||
* If no data was stored in the local store, or if the data was already retrieved by a previous call to fetchLocal,
|
||||
* do NOT call this method, or an exception will be thrown.
|
||||
*
|
||||
* Do not call this method from {@link AsyncTask#onProgressUpdate}, because this method deletes stored data, which
|
||||
* means that you will not be able to retrieve it again afterwards. Use {@link AsyncTask#peekLocal} instead to
|
||||
* Do not call this method from {@link AsyncTask::onProgressUpdate}, because this method deletes stored data, which
|
||||
* means that you will not be able to retrieve it again afterwards. Use {@link AsyncTask::peekLocal} instead to
|
||||
* retrieve stored data without removing it from the store.
|
||||
*
|
||||
* WARNING: THIS METHOD SHOULD ONLY BE CALLED FROM THE MAIN THREAD!
|
||||
@ -287,11 +287,11 @@ abstract class AsyncTask extends Collectable{
|
||||
|
||||
/**
|
||||
* Returns mixed data in thread-local storage on the parent thread **without clearing** it. Call this method from
|
||||
* {@link AsyncTask#onProgressUpdate} to fetch the data stored if you need to be able to access the data later on,
|
||||
* {@link AsyncTask::onProgressUpdate} to fetch the data stored if you need to be able to access the data later on,
|
||||
* such as in another progress update.
|
||||
*
|
||||
* Use {@link AsyncTask#fetchLocal} instead from {@link AsyncTask#onCompletion}, because this method does not delete
|
||||
* the data, and not clearing the data will result in a warning for memory leak after {@link AsyncTask#onCompletion}
|
||||
* Use {@link AsyncTask::fetchLocal} instead from {@link AsyncTask::onCompletion}, because this method does not delete
|
||||
* the data, and not clearing the data will result in a warning for memory leak after {@link AsyncTask::onCompletion}
|
||||
* finished executing.
|
||||
*
|
||||
* WARNING: THIS METHOD SHOULD ONLY BE CALLED FROM THE MAIN THREAD!
|
||||
|
Loading…
x
Reference in New Issue
Block a user