GenisysPro  for Minecraft PE/Windows 10 v1.1.x
Feature-rich server software for Minecraft PE and Windows 10 Edition
Thread Class Reference

Public Member Functions

 getClassLoader ()
 
 setClassLoader (\ClassLoader $loader=null)
 
 registerClassLoader ()
 
 start (int $options=PTHREADS_INHERIT_ALL)
 
 quit ()
 
 getThreadName ()
 
- Public Member Functions inherited from Thread
 getCreatorId ()
 
 getThreadId ()
 
 isJoined ()
 
 isStarted ()
 
 join ()
 
 start (int $options=PTHREADS_INHERIT_ALL)
 
- Public Member Functions inherited from Threaded
 chunk ($size, bool $preserve=false)
 
 count ()
 
 isRunning ()
 
 isTerminated ()
 
 merge ($from, $overwrite=true)
 
 notify ()
 
 notifyOne ()
 
 offsetGet ($offset)
 
 offsetSet ($offset, $value)
 
 offsetExists ($offset)
 
 offsetUnset ($offset)
 
 pop ()
 
 run ()
 
 shift ()
 
 synchronized (\Closure $function, $args=null)
 
 wait ($timeout)
 
 getRefCount ()
 
 addRef ()
 
 delRef ()
 
 isGarbage ()
 

Protected Attributes

 $classLoader
 
 $isKilled = false
 

Additional Inherited Members

- Static Public Member Functions inherited from Thread
static getCurrentThread ()
 
static getCurrentThreadId ()
 
- Static Public Member Functions inherited from Threaded
static extend ($obj)
 

Detailed Description

This class must be extended by all custom threading classes

Member Function Documentation

◆ getClassLoader()

getClassLoader ( )
Returns
45  {
46  return $this->classLoader;
47  }

◆ getThreadName()

getThreadName ( )
Returns
string
107  {
108  return (new \ReflectionClass($this))->getShortName();
109  }

◆ quit()

quit ( )

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

90  {
91  $this->isKilled = true;
92 
93  $this->notify();
94 
95  if(!$this->isJoined()){
96  if(!$this->isTerminated()){
97  $this->join();
98  }
99  }
100 
101  ThreadManager::getInstance()->remove($this);
102  }

◆ registerClassLoader()

registerClassLoader ( )
59  {
60  if(!interface_exists("ClassLoader", false)){
61  require(\pocketmine\PATH . "src/spl/ClassLoader.php");
62  require(\pocketmine\PATH . "src/spl/BaseClassLoader.php");
63  }
64  if($this->classLoader !== null){
65  $this->classLoader->register(true);
66  }
67  }

◆ setClassLoader()

setClassLoader ( \ClassLoader  $loader = null)
Parameters
\ClassLoader | null$loader
52  {
53  if($loader === null){
54  $loader = Server::getInstance()->getLoader();
55  }
56  $this->classLoader = $loader;
57  }

◆ start()

start ( int  $options = PTHREADS_INHERIT_ALL)
Parameters
int$options
Returns
bool
74  {
75  ThreadManager::getInstance()->add($this);
76 
77  if(!$this->isRunning() and !$this->isJoined() and !$this->isTerminated()){
78  if($this->getClassLoader() === null){
79  $this->setClassLoader();
80  }
81  return parent::start($options);
82  }
83 
84  return false;
85  }

Field Documentation

◆ $classLoader

$classLoader
protected

◆ $isKilled

$isKilled = false
protected

The documentation for this class was generated from the following file: