Documentation

Thread extends Thread
in package
Uses CommonThreadPartsTrait

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.

Tags
see
AsyncTask

Table of Contents

$composerAutoloaderPath  : string|null
$isKilled  : bool
$classLoaders  : Threaded|null
getClassLoaders()  : array<string|int, ClassLoader>
getThreadName()  : string
quit()  : void
Stops the thread using the best way possible. Try to stop it yourself before calling this.
registerClassLoaders()  : void
Registers the class loaders for this thread.
run()  : void
setClassLoaders()  : void
start()  : bool
onRun()  : void
Runs code on the thread.

Properties

Methods

quit()

Stops the thread using the best way possible. Try to stop it yourself before calling this.

public quit() : void
Return values
void

registerClassLoaders()

Registers the class loaders for this thread.

public registerClassLoaders() : void

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).

Return values
void

start()

public start([int $options = PTHREADS_INHERIT_NONE ]) : bool
Parameters
$options : int = PTHREADS_INHERIT_NONE
Return values
bool

Search results