32 private static ?
self $instance =
null;
34 public static function init() :
void{
39 if(self::$instance ===
null){
42 return self::$instance;
46 private ThreadSafeArray $threads;
48 private function __construct(){
49 $this->threads =
new ThreadSafeArray();
53 $this->threads[spl_object_id($thread)] = $thread;
57 unset($this->threads[spl_object_id($thread)]);
68 foreach($this->threads as $key => $thread){
69 $array[$key] = $thread;
75 public function stopAll() : int{
80 foreach($this->getAll() as $thread){
81 $logger->debug(
"Stopping " . $thread->getThreadName() .
" thread");
84 $logger->debug($thread->getThreadName() .
" thread stopped successfully.");
85 }
catch(ThreadException $e){
87 $logger->debug(
"Could not stop " . $thread->getThreadName() .
" thread: " . $e->getMessage());
91 return $erroredThreads;