/** * Creates a new Condition Variable for the caller. * * @link http://www.php.net/manual/en/cond.create.php * @return int A handle to a Condition Variable */ public static function create() { return fhread_cond_init(); }
/** * Start method which will prepare, create and starts a thread * * @return boolean pthread create state */ public function start() { // check if was started already if ($this->getState() >= self::STATE_STARTED && $this->getState() < self::STATE_JOINED) { throw new \Exception('Thread has been started already!'); } $this->setState(self::STATE_STARTED); // init thread cond $this->syncNotify = fhread_cond_init(); // init thread mutex $this->globalMutex = fhread_mutex_init(); $this->stateMutex = fhread_mutex_init(); $this->syncMutex = fhread_mutex_init(); // create, start thread and save thread id if (fhread_create($this, $this->threadId, $this->fhreadHandle) === 0) { $this->setState(self::STATE_RUNNING); return true; } $this->setState(self::STATE_ERROR); return false; }