Beispiel #1
0
 /**
  * Add an lock to the list of active locks
  *
  * @param Lock $lock The lock to add
  */
 private function add(Lock $lock)
 {
     $index = count($this->locks);
     if ($lock->getToken()) {
         $this->tokens[$lock->getToken()] = $index;
     }
     $type = $lock->getType();
     $scope = $lock->getScope();
     $hashKey = $this->getHashKey($type, $scope);
     if (!isset($this->index[$type])) {
         $this->index[$type] = array();
     }
     if (!isset($this->index[$hashKey])) {
         $this->index[$hashKey] = array();
     }
     $this->index[$type][] = $index;
     $this->index[$hashKey][] = $index;
     $this->locks[] = $lock;
 }
Beispiel #2
0
 public function testDefaultScope()
 {
     $this->assertEquals('exclusive', $this->lock->getScope());
     $this->assertTrue($this->lock->isExclusive());
 }