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

Public Member Functions

 getClassLoader ()
 
 setClassLoader (\ClassLoader $loader=null)
 
 registerClassLoader ()
 
 start (int $options=PTHREADS_INHERIT_ALL)
 
 quit ()
 
 getThreadName ()
 
- Public Member Functions inherited from Worker
 getStacked ()
 
 isShutdown ()
 
 collector (Collectable $collectable)
 
 shutdown ()
 
 stack (Collectable &$work)
 
 unstack ()
 
 collect (callable $function)
 
- 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
46  {
47  return $this->classLoader;
48  }

◆ getThreadName()

getThreadName ( )
Returns
string
112  {
113  return (new \ReflectionClass($this))->getShortName();
114  }

◆ quit()

quit ( )

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

91  {
92  $this->isKilled = true;
93 
94  $this->notify();
95 
96  if($this->isRunning()){
97  $this->shutdown();
98  $this->notify();
99  $this->unstack();
100  }elseif(!$this->isJoined()){
101  if(!$this->isTerminated()){
102  $this->join();
103  }
104  }
105 
106  ThreadManager::getInstance()->remove($this);
107  }

◆ registerClassLoader()

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

◆ setClassLoader()

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

◆ start()

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

Field Documentation

◆ $classLoader

$classLoader
protected

◆ $isKilled

$isKilled = false
protected

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