Skip to content

Commit 6225500

Browse files
committed
Improved docs to not use process but instance instead
1 parent c588def commit 6225500

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

components/lock.rst

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,17 +153,23 @@ object) and ``isExpired()`` (which returns a boolean).
153153
The Owner of The Lock
154154
---------------------
155155

156-
Locks that are acquired for the first time are owned by the process that acquired
157-
it. If you need to check whether the current process is (still) the owner of
158-
a process, you can use the ``isAcquired()`` method::
156+
Locks that are acquired for the first time are owned by the ``Lock`` instance[1]_ that acquired
157+
it. If you need to check whether the current ``Lock`` instance is (still) the owner of
158+
a lock, you can use the ``isAcquired()`` method::
159159

160160
if ($lock->isAcquired()) {
161-
// This process (still) owns the lock
161+
// We (still) own the lock
162162
}
163163

164+
.. note::
165+
166+
[1] Technically, the true owners of the lock are the ones that share the same instance of ``Key``,
167+
not ``Lock``. But from a user perspective, ``Key`` is internal and you will likely only be working
168+
with the ``Lock`` instance so it's easier to think of the ``Lock`` instance as being the one that
169+
is the owner of the lock.
164170

165171
Because of the fact that some lock stores have expiring locks (as seen and explained
166-
above), it is possible for a process to lose the lock it acquired automatically::
172+
above), it is possible for an instance to lose the lock it acquired automatically::
167173

168174
// If we cannot acquire ourselves, it means some other process is already working on it
169175
if (!$lock->acquire()) {
@@ -175,7 +181,7 @@ above), it is possible for a process to lose the lock it acquired automatically:
175181
// Perform a very long process that might exceed TTL of the lock
176182

177183
if ($lock->isAcquired()) {
178-
// Still all good, no other process has acquired the lock in the meantime, we're safe
184+
// Still all good, no other instance has acquired the lock in the meantime, we're safe
179185
$this->commit();
180186
} else {
181187
// Bummer! Our lock has apparently exceeded TTL and another process has started in

0 commit comments

Comments
 (0)