public function ensure_thread()
    {
        if (!$this->is_thread_running)
        {
            $this->is_thread_running = true;
            $this->thread_cond = \Cond::create();
            $this->thread_mutex = \Mutex::create();
            $this->start();
        }
    }