3 namespace Friendica\Core;
5 use Friendica\Core\Lock\ILock;
8 * Basic class for Locking with common functions (local acquired locks, releaseAll, ..)
10 abstract class BaseLock implements ILock
13 * @var array The local acquired locks
15 protected $acquiredLocks = [];
18 * Check if we've locally acquired a lock
20 * @param string key The Name of the lock
22 * @return bool Returns true if the lock is set
24 protected function hasAcquiredLock($key)
26 return isset($this->acquireLock[$key]) && $this->acquiredLocks[$key] === true;
30 * Mark a locally acquired lock
32 * @param string $key The Name of the lock
34 protected function markAcquire($key)
36 $this->acquiredLocks[$key] = true;
40 * Mark a release of a locally acquired lock
42 * @param string $key The Name of the lock
44 protected function markRelease($key)
46 unset($this->acquiredLocks[$key]);
52 public function releaseAll($override = false)
56 foreach ($this->acquiredLocks as $acquiredLock => $hasLock) {
57 if (!$this->release($acquiredLock, $override)) {