mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-21 00:07:30 +00:00
Improve documentation of Thread and Worker
This commit is contained in:
parent
32588d79c8
commit
f5c9c02e09
@ -23,10 +23,17 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\thread;
|
||||
|
||||
use pocketmine\scheduler\AsyncTask;
|
||||
use const PTHREADS_INHERIT_NONE;
|
||||
|
||||
/**
|
||||
* This class must be extended by all custom threading classes
|
||||
* Specialized Thread class aimed at PocketMine-MP-related usages. It handles setting up autoloading and error handling.
|
||||
*
|
||||
* Note: You probably don't need a thread unless you're doing something in it that's expected to last a long time (or
|
||||
* indefinitely).
|
||||
* For CPU-demanding tasks that take a short amount of time, consider using AsyncTasks instead to make better use of the
|
||||
* CPU.
|
||||
* @see AsyncTask
|
||||
*/
|
||||
abstract class Thread extends \Thread{
|
||||
use CommonThreadPartsTrait;
|
||||
|
@ -26,7 +26,14 @@ namespace pocketmine\thread;
|
||||
use const PTHREADS_INHERIT_NONE;
|
||||
|
||||
/**
|
||||
* This class must be extended by all custom threading classes
|
||||
* Specialized Worker class for PocketMine-MP-related use cases. It handles setting up autoloading and error handling.
|
||||
*
|
||||
* Workers are a special type of thread which execute tasks passed to them during their lifetime. Since creating a new
|
||||
* thread has a high resource cost, workers can be kept around and reused for lots of short-lived tasks.
|
||||
*
|
||||
* As a plugin developer, you'll rarely (if ever) actually need to use this class directly.
|
||||
* If you want to run tasks on other CPU cores, check out AsyncTask first.
|
||||
* @see AsyncTask
|
||||
*/
|
||||
abstract class Worker extends \Worker{
|
||||
use CommonThreadPartsTrait;
|
||||
|
Loading…
x
Reference in New Issue
Block a user