@@ 163-178 (lines=16) @@ | ||
160 | ||
161 | if ($mode & self::LOCK_CAPABILITY_EXCLUSIVE) { |
|
162 | ||
163 | if ($mode & self::LOCK_CAPABILITY_NOBLOCK) { |
|
164 | ||
165 | $this->isAcquired = $this->lock(); |
|
166 | ||
167 | if (!$this->isAcquired) { |
|
168 | throw new LockAcquireWouldBlockException('could not acquire lock'); |
|
169 | } |
|
170 | } else { |
|
171 | ||
172 | // this blocks till the lock gets released or timeout is reached |
|
173 | if (!$this->wait($this->blTo)) { |
|
174 | throw new LockAcquireException('could not acquire lock'); |
|
175 | } |
|
176 | ||
177 | $this->isAcquired = $this->lock(); |
|
178 | } |
|
179 | ||
180 | } else { |
|
181 | throw new LockAcquireException('insufficient capabilities'); |
@@ 166-190 (lines=25) @@ | ||
163 | } |
|
164 | ||
165 | //if ($mode & self::LOCK_CAPABILITY_EXCLUSIVE) { |
|
166 | if ($mode) { |
|
167 | ||
168 | //if ($mode & self::LOCK_CAPABILITY_NOBLOCK) { |
|
169 | if (!$mode) { |
|
170 | ||
171 | // this does not block |
|
172 | $this->isAcquired = $this->lock(); |
|
173 | ||
174 | if (!$this->isAcquired) { |
|
175 | //throw new LockAcquireWouldBlockException('could not acquire lock'); |
|
176 | throw new \Exception('could not acquire lock'); |
|
177 | } |
|
178 | } else { |
|
179 | ||
180 | if(!$this->wait($this->blTo)) { |
|
181 | //throw new LockAcquireException('could not acquire lock'); |
|
182 | throw new \Exception('could not acquire lock'); |
|
183 | } |
|
184 | ||
185 | $this->isAcquired = $this->lock(); |
|
186 | } |
|
187 | } else { |
|
188 | //throw new LockAcquireException('insufficient capabilities'); |
|
189 | throw new \Exception('insufficient capabilities'); |
|
190 | } |
|
191 | ||
192 | echo $this->id.' acquired lock: '.$this->value.PHP_EOL; |
|
193 |