{@inheritdoc}

@see \Concrete\Core\System\Mutex\MutexInterface::acquire()
349697
public function acquire($key)
    {
        $filename = $this->getFilenameForMutexKey($key);
        if (isset($this->resources[$key])) {
            $fd = $this->resources[$key];
            if (is_resource($fd)) {
                throw new MutexBusyException($key);
            }
        }
        @touch($filename);
        @chmod($filename, 0666);
        $fd = @fopen($filename, 'r+');
        if (!is_resource($fd) || @flock($fd, LOCK_EX | LOCK_NB) !== true) {
            throw new MutexBusyException($key);
        }
        $this->resources[$key] = $fd;
    }
151083
int acquireTransaction(@NotNull final Thread thread) {
        try (CriticalSection ignored = criticalSection.enter()) {
            final int currentThreadPermits = getThreadPermitsToAcquire(thread);
            waitForPermits(thread, currentThreadPermits > 0 ? nestedQueue : regularQueue, 1, currentThreadPermits);
        }
        return 1;
    }
58614
public function acquire()
    {
        $results = $this->redis->eval(
            $this->luaScript(), 1, $this->name, microtime(true), time(), $this->decay, $this->maxLocks
        );

        $this->decaysAt = $results[1];

        $this->remaining = max(0, $results[2]);

        return (bool) $results[0];
    }
539172
public function unlock(string $id) : LockableInterface
    {
        if (isset($this->locks[$id]) === true) {
            unset($this->locks[$id]);
        }
        return $this;
    }
608735
private function acquireLock()
    {
        if (file_exists($this->lockFile)) {
            $stale_after = filemtime($this->lockFile) + $this->maxLockAge;
            if (time() > $stale_after) {
                // The lockfile is stale, delete it and reacquire a lock
                @rmdir($this->lockFile);
            } else {
                // The lockfile is valid, WURFL is probably being reloaded in another thread
                return false;
            }
        }
        
        // Using mkdir instead of touch since mkdir is atomic
        $this->isLocked = @mkdir($this->lockFile, 0775);
        return $this->isLocked;
    }
292959
public function dispatchToQueue($command)
    {
        $connection = $command->connection ?? null;

        $queue = call_user_func($this->queueResolver, $connection);

        if (! $queue instanceof Queue) {
            throw new RuntimeException('Queue resolver did not return a Queue implementation.');
        }

        if (method_exists($command, 'queue')) {
            return $command->queue($queue, $command);
        }

        return $this->pushCommandToQueue($queue, $command);
    }
46011
public function acquire($blocking = true)
    {
        if ($this->locked) {
            throw new \RuntimeException('already lock by yourself');
        }

        if ($blocking) {
            $locked = flock($this->fp, LOCK_EX);
        } else {
            $locked = flock($this->fp, LOCK_EX | LOCK_NB);
        }

        if ($locked !== true) {
            return false;
        }
        $this->locked = true;

        return true;
    }
517276
public function acquire($context = SessionPoolInterface::CONTEXT_READ)
    {
        // Try to get a session, run maintenance on the pool, and calculate if
        // we need to create any new sessions.
        list($session, $toCreate) = $this->config['lock']->synchronize(function () {
            $toCreate = [];
            $session = null;
            $shouldSave = false;
            $item = $this->cacheItemPool->getItem($this->cacheKey);
            $data = (array) $item->get() ?: $this->initialize();

            // If the queue has items in it, let's shift one off, however if the
            // queue is empty and we have maxed out the number of sessions let's
            // attempt to purge any orphaned items from the pool to make room
            // for more.
            if ($data['queue']) {
                $session = $this->getSession($data);
                $shouldSave = true;
            } elseif ($this->config['maxSessions'] <= $this->getSessionCount($data)) {
                $this->purgeOrphanedInUseSessions($data);
                $this->purgeOrphanedToCreateItems($data);
                $session = $this->getSession($data);
                $shouldSave = true;
            }

            if (!$session) {
                $count = $this->getSessionCount($data);

                if ($count < $this->config['maxSessions']) {
                    $toCreate = $this->buildToCreateList(1);
                    $data['toCreate'] += $toCreate;
                    $shouldSave = true;
                }
            }

            if ($shouldSave) {
                $this->cacheItemPool->save($item->set($data));
            }

            return [$session, $toCreate];
        });

        // Create a session if needed.
        if ($toCreate) {
            $createdSessions = $this->createSessions(count($toCreate));
            $hasCreatedSessions = count($createdSessions) > 0;

            $session = $this->config['lock']->synchronize(function () use (
                $toCreate,
                $createdSessions,
                $hasCreatedSessions
            ) {
                $session = null;
                $item = $this->cacheItemPool->getItem($this->cacheKey);
                $data = $item->get();
                $data['queue'] = array_merge($data['queue'], $createdSessions);

                // Now that we've created the session, we can remove it from
                // the list of intent.
                foreach ($toCreate as $id => $time) {
                    unset($data['toCreate'][$id]);
                }

                if ($hasCreatedSessions) {
                    $session = array_shift($data['queue']);
                    $data['inUse'][$session['name']] = $session + [
                        'lastActive' => $this->time()
                    ];

                    if ($this->config['shouldAutoDownsize']) {
                        $this->manageSessionsToDelete($data);
                    }
                }

                $this->cacheItemPool->save($item->set($data));

                return $session;
            });
        }

        if ($session) {
            $session = $this->handleSession($session);
        }

        // If we don't have a session, let's wait for one or throw an exception.
        if (!$session) {
            if (!$this->config['shouldWaitForSession']) {
                throw new \RuntimeException('No sessions available.');
            }

            $session = $this->waitForNextAvailableSession();
        }

        if ($this->deleteQueue) {
            $this->deleteSessions($this->deleteQueue);
            $this->deleteQueue = [];
        }

        return $this->database->session($session['name']);
    }
372165
def acquire(self,blocking=True,timeout=None,shared=False):
        """"""
        with self._lock:
            if shared:
                self._acquire_shared(blocking,timeout)
            else:
                self._acquire_exclusive(blocking,timeout)
            assert not (self.is_shared and self.is_exclusive)
921878
def acquire(self):
        
        # handle thread lock
        if Handler:
            # under some tests Handler ends up being null due to instantiation
            # order
            Handler.acquire(self)

        # Issue a file lock.  (This is inefficient for multiple active threads
        # within a single process. But if you're worried about high-performance,
        # you probably aren't using this log handler.)
        if self.stream_lock:
            # If stream_lock=None, then assume close() was called or something
            # else weird and ignore all file-level locks.
            if self.stream_lock.closed:
                # Daemonization can close all open file descriptors, see
                # https://bugzilla.redhat.com/show_bug.cgi?id=952929
                # Try opening the lock file again.  Should we warn() here?!?
                try:
                    self._open_lockfile()
                except Exception:
                    self.handleError(NullLogRecord())
                    # Don't try to open the stream lock again
                    self.stream_lock = None
                    return
            lock(self.stream_lock, LOCK_EX)
859077
public function offsetGet($offset)
    {
        isset($this->keys[$offset])
            || Exception::unknownProperty($offset);
        if (
            isset($this->raw[$offset])
            || !is_object($this->items[$offset])
            || isset($this->protect[$this->items[$offset]])
            || !method_exists($this->items[$offset], '__invoke')
        ) {
            return $this->items[$offset];
        }

        if (isset($this->factory[$this->items[$offset]])) {
            return $this->items[$offset]($this);
        }

        $raw = $this->items[$offset];
        $val = $this->items[$offset] = $raw($this);
        $this->raw[$offset] = $raw;
        $this->frozen[$offset] = true;
        return $val;
    }
247010
public static final void acquireMultiple(long timeout, CMutex mutex[])
			throws RuntimeException {
		Arrays.sort(mutex, new CMutexComparator());
		for (int i = 0; i < mutex.length; i++) {
			try {
				mutex[i].acquire(timeout);
			} catch (RuntimeException re) {
				// release successfuly acquired mutex.
				for (int j = i - 1; j >= 0; j--) {
					if (mutex[j].isOwner()) {
						mutex[j].release();
					}
				}
				throw re;
			}
		}
	}
1274582
private function acquire_lock($acquire_timeout = 10) {
		$identifier = (string)Uuid::uuid4();

		$end = time() + $acquire_timeout;
		while (time() < $end) {
			$res = $this->client->setnx('lock:' . $this->name, $identifier);
			if ($res) {
				return $identifier;
			}
			sleep(0.001);
		}
		return false;
	}
727461
public static function _acquire( $filename )
    {
        if (function_exists('sem_get')) {
            @sem_acquire(self::getResource(hexdec(md5($filename))));
            return true;
        } else {
            // Generate filename
            $lockfile = $filename.'.lock';

            // Wait until lock expired or gone
            while(file_exists($lockfile)) {
                $lockExpires = intval(@file_get_contents($lockfile));
                if($lockExpires<time()) {
                    unlink($lockfile);
                } else {
                    usleep(self::LOCK_WAIT);
                }
            }

            // Create a lock
            return file_put_contents($lockfile, sprintf("%d",time()+5)) !== false;
        }
    }
1022799
function acquire()
    {
        if ( $this->isLocked() )
            // resource is locked
            return false;


        $lockRes = static::_getLocksDir("{$this->realm}.lockfile");
        if (false === $this->file = $file = fopen($lockRes, 'w+') )
            throw new \RuntimeException(sprintf(
                'Failed To Open Resource (%s).'
                , $lockRes
            ));

        if (! flock($file, LOCK_EX | LOCK_NB, $wouldBlock) ) {
            if ($wouldBlock)
                // another process holds the lock
                return false;

            throw new \RuntimeException(sprintf(
                'FAILED to acquire lock[%s] on resource (%s).'
                , $this->realm
                , $lockRes
            ));
        }



        ftruncate($file, 0);
        fwrite($file, sprintf("(%s): Locked Accrued. \n", date('Y-m-d H:i:s')));
        fflush($file);

        return true;
    }
598384
protected function setMutex()
    {
        if (Eye::laravelVersionIs('<', '5.4.0')) {
            return touch($this->mutexPath());
        } elseif (Eye::laravelVersionIs('<', '5.4.17')) {
            return $this->cache->add($this->mutexName(), true, 1440);
        }

        return $this->mutex->create($this);
    }
651629
public function newInstance($className)
    {

        // lock the method
        \Mutex::lock($this->mutex);

        // we're not dispatched
        $this->dispatched = false;

        // initialize the data
        $this->className = $className;

        // notify the thread
        $this->notify();

        // wait till we've dispatched the request
        while ($this->dispatched === false) {
            usleep(100);
        }

        // try to load the last created instance
        if (isset($this->instances[$last = sizeof($this->instances) - 1])) {
            $instance = $this->instances[$last];
        } else {
            throw new \Exception('Requested instance can\'t be created');
        }

        // unlock the method
        \Mutex::unlock($this->mutex);

        // return the created instance
        return $instance;
    }