Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 8922a99

Browse filesBrowse files
committed
Merge branch '5.2' into 5.x
* 5.2: [Lock] Added paragraph about auto release Fixed typo for YamlEncoder section
2 parents 76bc4b1 + e1714db commit 8922a99
Copy full SHA for 8922a99

File tree

2 files changed

+33
-1
lines changed
Filter options

2 files changed

+33
-1
lines changed

‎components/lock.rst

Copy file name to clipboardExpand all lines: components/lock.rst
+32Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,38 @@ This component also provides two useful methods related to expiring locks:
207207
``getRemainingLifetime()`` (which returns ``null`` or a ``float``
208208
as seconds) and ``isExpired()`` (which returns a boolean).
209209

210+
Automatically Releasing The Lock
211+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
212+
213+
Lock are automatically released when their Lock objects are destructed. This is
214+
an implementation detail that will be important when sharing Locks between
215+
processes. In the example below, ``pcntl_fork()`` creates two processes and the
216+
Lock will be released automatically as soon as one process finishes::
217+
218+
// ...
219+
$lock = $factory->createLock('report-generation', 3600);
220+
if (!$lock->acquire()) {
221+
return;
222+
}
223+
224+
$pid = pcntl_fork();
225+
if (-1 === $pid) {
226+
// Could not fork
227+
exit(1);
228+
} elseif ($pid) {
229+
// Parent process
230+
sleep(30);
231+
} else {
232+
// Child process
233+
echo 'The lock will be released now.'
234+
exit(0);
235+
}
236+
// ...
237+
238+
To disable this behavior, set to ``false`` the third argument of
239+
``LockFactory::createLock()``. That will make the lock acquired for 3600 seconds
240+
or until ``Lock::release()`` is called.
241+
210242
Shared Locks
211243
------------
212244

‎components/serializer.rst

Copy file name to clipboardExpand all lines: components/serializer.rst
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1043,7 +1043,7 @@ The ``YamlEncoder`` Context Options
10431043
The ``encode()`` method, like other encoder, uses ``context`` to set
10441044
configuration options for the YamlEncoder an associative array::
10451045

1046-
$xmlEncoder->encode($array, 'xml', $context);
1046+
$yamlEncoder->encode($array, 'yaml', $context);
10471047

10481048
These are the options available:
10491049

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.