Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions components/lock.rst
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ method, the resource will stay locked until the timeout::
// create an expiring lock that lasts 30 seconds
$lock = $factory->createLock('charts-generation', 30);

$lock->acquire();
if (!$lock->acquire()) {
return;
}
try {
// perform a job during less than 30 seconds
} finally {
Expand All @@ -136,7 +138,9 @@ to reset the TTL to its original value::
// ...
$lock = $factory->createLock('charts-generation', 30);

$lock->acquire();
if (!$lock->acquire()) {
return;
}
try {
while (!$finished) {
// perform a small part of the job.
Expand Down Expand Up @@ -366,7 +370,9 @@ Using the above methods, a more robust code would be::
// ...
$lock = $factory->createLock('invoice-publication', 30);

$lock->acquire();
if (!$lock->acquire()) {
return;
}
while (!$finished) {
if ($lock->getRemainingLifetime() <= 5) {
if ($lock->isExpired()) {
Expand Down