doc: Expand section related to LWLocks and shared memory

Michael Paquier <michael@paquier.xyz>

Commit: fe705ef6fc1d1b4b48aea94a1dd2835a6630dacf
Author: Michael Paquier <michael@paquier.xyz>
Date: 2023-11-01T05:54:13Z
Releases: 17.0
doc: Expand section related to LWLocks and shared memory

The documentation includes a section describing how to define custom
LWLocks in extensions using the shmem hooks.  However, it has never
mentioned the second, more flexible method based on the following
routines:
- LWLockNewTrancheId() to allocate a tranche ID.
- LWLockRegisterTranche() to associate a name to a tranche ID.
- LWLockInitialize() to initialize a LWLock with a tranche ID.

autoprewarm.c is the only example of extension in the tree that
allocates a LWLock this way.

This commit adds some documentation about all that.  While on it, a
comment is added about the need of AddinShmemInitLock.  This is required
especially for EXEC_BACKEND builds (aka Windows, normally), as per a
remark from Alexander, because backends can execute shmem initialization
paths concurrently.

Author: Aleksander Alekseev, Michael Paquier
Discussion: https://postgr.es/m/CAJ7c6TPKhFgL+54cdTD9yGpG4+sNcyJ+N1GvQqAxgWENAOa3VA@mail.gmail.com

Files

PathChange+/−
doc/src/sgml/xfunc.sgml modified +30 −0

Documentation touched

Discussion