Skip to content

Commit d03d754

Browse files
committed
Use macros instead of hardcoded offsets for LWLock initialization
This makes the code slightly easier to follow, as the initialization relies on an offset that overlapped with an equivalent set of macros defined, which are used in other places already. Author: Japin Li Discussion: https://postgr.es/m/MEYP282MB1669FB410006758402F2C3A2B6E00@MEYP282MB1669.AUSP282.PROD.OUTLOOK.COM
1 parent 789b938 commit d03d754

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/backend/storage/lmgr/lwlock.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -525,18 +525,17 @@ InitializeLWLocks(void)
525525
LWLockInitialize(&lock->lock, id);
526526

527527
/* Initialize buffer mapping LWLocks in main array */
528-
lock = MainLWLockArray + NUM_INDIVIDUAL_LWLOCKS;
528+
lock = MainLWLockArray + BUFFER_MAPPING_LWLOCK_OFFSET;
529529
for (id = 0; id < NUM_BUFFER_PARTITIONS; id++, lock++)
530530
LWLockInitialize(&lock->lock, LWTRANCHE_BUFFER_MAPPING);
531531

532532
/* Initialize lmgrs' LWLocks in main array */
533-
lock = MainLWLockArray + NUM_INDIVIDUAL_LWLOCKS + NUM_BUFFER_PARTITIONS;
533+
lock = MainLWLockArray + LOCK_MANAGER_LWLOCK_OFFSET;
534534
for (id = 0; id < NUM_LOCK_PARTITIONS; id++, lock++)
535535
LWLockInitialize(&lock->lock, LWTRANCHE_LOCK_MANAGER);
536536

537537
/* Initialize predicate lmgrs' LWLocks in main array */
538-
lock = MainLWLockArray + NUM_INDIVIDUAL_LWLOCKS +
539-
NUM_BUFFER_PARTITIONS + NUM_LOCK_PARTITIONS;
538+
lock = MainLWLockArray + PREDICATELOCK_MANAGER_LWLOCK_OFFSET;
540539
for (id = 0; id < NUM_PREDICATELOCK_PARTITIONS; id++, lock++)
541540
LWLockInitialize(&lock->lock, LWTRANCHE_PREDICATE_LOCK_MANAGER);
542541

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy