From 6fa59230db88c4c0e779ebf6a18491ed63c6177d Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sat, 22 Jul 2017 10:55:00 +0100 Subject: [PATCH] Added documentation for Thread->registerClassLoader() and Worker->registerClassLoader() --- src/pocketmine/Thread.php | 7 +++++++ src/pocketmine/Worker.php | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/src/pocketmine/Thread.php b/src/pocketmine/Thread.php index 0213dcc58..1f1be497c 100644 --- a/src/pocketmine/Thread.php +++ b/src/pocketmine/Thread.php @@ -43,6 +43,13 @@ abstract class Thread extends \Thread{ $this->classLoader = $loader; } + /** + * Registers the class loader for this thread. + * + * WARNING: This method MUST be called from any descendent threads' run() method to make autoloading usable. + * If you do not do this, you will not be able to use new classes that were not loaded when the thread was started + * (unless you are using a custom autoloader). + */ public function registerClassLoader(){ if(!interface_exists("ClassLoader", false)){ require(\pocketmine\PATH . "src/spl/ClassLoader.php"); diff --git a/src/pocketmine/Worker.php b/src/pocketmine/Worker.php index 94d990c1a..85e3dedf9 100644 --- a/src/pocketmine/Worker.php +++ b/src/pocketmine/Worker.php @@ -44,6 +44,13 @@ abstract class Worker extends \Worker{ $this->classLoader = $loader; } + /** + * Registers the class loader for this thread. + * + * WARNING: This method MUST be called from any descendent threads' run() method to make autoloading usable. + * If you do not do this, you will not be able to use new classes that were not loaded when the thread was started + * (unless you are using a custom autoloader). + */ public function registerClassLoader(){ if(!interface_exists("ClassLoader", false)){ require(\pocketmine\PATH . "src/spl/ClassLoader.php");