コード例 #1
0
ファイル: DbTree.php プロジェクト: jstacoder/brushfire
 function __call($fnName, $args)
 {
     if (in_array($fnName, self::$functionExceptions)) {
         return call_user_func_array(array($this, $fnName), $args);
     }
     //get node (since all private functions require it)
     $node = $args[0] = $this->getNode($args[0]);
     if ($this->fkColumn) {
         $this->baseWhere[$this->fkColumn] = $node[$this->fkColumn];
     }
     //get foreign key to localise lock
     $lockName = 'DbTree-' . $this->table;
     if ($this->fkColumn) {
         $lockName .= '-' . $node[$this->fkColumn];
     }
     $this->__methodExists($fnName);
     Lock::req($lockName, 2);
     $this->db->db->beginTransaction();
     try {
         $return = call_user_func_array(array($this, $fnName), $args);
         $this->db->db->commit();
     } catch (Exception $e) {
         Lock::off($lockName);
         $this->db->db->rollBack();
         throw $e;
     }
     Lock::off($lockName);
     return $return;
 }
コード例 #2
0
ファイル: Cron.php プロジェクト: jstacoder/brushfire
 static function stop()
 {
     Debug::out('Stopping');
     //set lock to tell existing cron to turn off
     if (!Lock::on('cron-off-' . $_ENV['projectName'])) {
         Debug::quit('Lock off failed');
     }
     echo "\n";
     //wait for exist cron to turn off
     while (Lock::isOn('cron-running-' . $_ENV['projectName'])) {
         echo '.';
         sleep(1);
     }
     //remove lock off
     Lock::off('cron-off-' . $_ENV['projectName']);
     Debug::out('Stopped');
 }