3 namespace Friendica\Core\Lock;
6 * Class AbstractLockDriver
8 * @package Friendica\Core\Lock
10 * @brief Basic class for Locking with common functions (local acquired locks, releaseAll, ..)
12 abstract class AbstractLockDriver implements ILockDriver
15 * @var array The local acquired locks
17 protected $acquiredLocks = [];
20 * @brief Check if we've locally acquired a lock
22 * @param string key The Name of the lock
23 * @return bool Returns true if the lock is set
25 protected function hasAcquiredLock(string $key) {
26 return isset($this->acquireLock[$key]);
30 * @brief Mark a locally acquired lock
32 * @param string $key The Name of the lock
34 protected function markAcquire(string $key) {
35 $this->acquiredLocks[$key] = true;
39 * @brief Mark a release of a locally acquired lock
41 * @param string $key The Name of the lock
43 protected function markRelease(string $key) {
44 unset($this->acquiredLocks[$key]);
48 * @brief Releases all lock that were set by us
52 public function releaseAll() {
53 foreach ($this->acquiredLocks as $acquiredLock) {
54 $this->releaseLock($acquiredLock);