RakLibServer
extends Thread
in package
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.
Table of Contents
- $crashInfo : RakLibThreadCrashInfo|null
- $cleanShutdown : bool
- $composerAutoloaderPath : string|null
- $isKilled : bool
- $logger : ThreadedLogger
- $mainPath : string
- $mainThreadNotifier : SleeperNotifier
- $mainToThreadBuffer : Threaded
- $maxMtuSize : int
- $ready : bool
- $serverId : int
- $threadToMainBuffer : Threaded
- $address : InternetAddress
- $classLoaders : Threaded|null
- $protocolVersion : int
- __construct() : mixed
- getClassLoaders() : array<string|int, ClassLoader>
- getCrashInfo() : RakLibThreadCrashInfo|null
- 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
- shutdownHandler() : void
- start() : bool
- startAndWait() : void
- onRun() : void
- setCrashInfo() : void
Properties
$crashInfo
public
RakLibThreadCrashInfo|null
$crashInfo
= null
$cleanShutdown
protected
bool
$cleanShutdown
= false
$composerAutoloaderPath
protected
string|null
$composerAutoloaderPath
$isKilled
protected
bool
$isKilled
= false
$logger
protected
ThreadedLogger
$logger
$mainPath
protected
string
$mainPath
$mainThreadNotifier
protected
SleeperNotifier
$mainThreadNotifier
$mainToThreadBuffer
protected
Threaded
$mainToThreadBuffer
$maxMtuSize
protected
int
$maxMtuSize
$ready
protected
bool
$ready
= false
$serverId
protected
int
$serverId
$threadToMainBuffer
protected
Threaded
$threadToMainBuffer
$address
private
InternetAddress
$address
$classLoaders
private
Threaded|null
$classLoaders
= null
$protocolVersion
private
int
$protocolVersion
Methods
__construct()
public
__construct(ThreadedLogger $logger, Threaded $mainToThreadBuffer, Threaded $threadToMainBuffer, InternetAddress $address, int $serverId, int $maxMtuSize, int $protocolVersion, SleeperNotifier $sleeper) : mixed
Parameters
- $logger : ThreadedLogger
- $mainToThreadBuffer : Threaded
- $threadToMainBuffer : Threaded
- $address : InternetAddress
- $serverId : int
- $maxMtuSize : int
- $protocolVersion : int
- $sleeper : SleeperNotifier
Return values
mixed —getClassLoaders()
public
getClassLoaders() : array<string|int, ClassLoader>
Return values
array<string|int, ClassLoader> —getCrashInfo()
public
getCrashInfo() : RakLibThreadCrashInfo|null
Return values
RakLibThreadCrashInfo|null —getThreadName()
public
getThreadName() : string
Return values
string —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 —run()
public
final run() : void
Return values
void —setClassLoaders()
public
setClassLoaders([array<string|int, ClassLoader> $autoloaders = null ]) : void
Parameters
- $autoloaders : array<string|int, ClassLoader> = null
Return values
void —shutdownHandler()
public
shutdownHandler() : void
Return values
void —start()
public
start([int $options = PTHREADS_INHERIT_NONE ]) : bool
Parameters
- $options : int = PTHREADS_INHERIT_NONE
Return values
bool —startAndWait()
public
startAndWait([int $options = PTHREADS_INHERIT_NONE ]) : void
Parameters
- $options : int = PTHREADS_INHERIT_NONE
Return values
void —onRun()
protected
onRun() : void
Return values
void —setCrashInfo()
private
setCrashInfo(RakLibThreadCrashInfo $info) : void
Parameters
- $info : RakLibThreadCrashInfo