Re: FlexLocks

From: Greg Stark <stark(at)mit(dot)edu>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Kevin Grittner <Kevin(dot)Grittner(at)wicourts(dot)gov>, Simon Riggs <simon(at)2ndquadrant(dot)com>, Alvaro Herrera <alvherre(at)commandprompt(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: FlexLocks
Date: 2011-11-16 16:14:40
Message-ID: CAM-w4HNxn29Jg-JnF976ALx4vnSCbDRgucOye_2TpBe_bPnbhA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Nov 16, 2011 at 3:41 PM, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
>  Now, you're always going to use
> LWLockAcquire() and LWLockRelease() to acquire and release an LWLock,
> but a FlexLockId isn't guaranteed to be an LWLockId - any given value
> might also refer to a FlexLock of some other type.  If we let everyone
> continue to refer to those things as LWLockIds, then it seems like
> only a matter of time before someone has a variable that's declared as
> LWLockId but actually doesn't refer to an LWLock at all.  I think it's
> better to bite the bullet and do the renaming up front, rather than
> having to think about it every time you modify some code that uses
> LWLockId or LWLockHeldByMe and say to yourself, "oh, wait a minute, is
> this really guaranteed to be an LWLock?"

But that's an advantage to having a distinct API layer for LWLock
instead of having callers directly call FlexLock methods. The LWLock
macros can AssertMacro that the lockid they were passed are actually
LWLocks and not some other type of lock. That would require assigning
FlexLockIds that are recognizably LWLocks but that's not implausible
is it?

--
greg

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Kevin Grittner 2011-11-16 16:17:42 Re: FlexLocks
Previous Message Robert Haas 2011-11-16 16:09:19 Re: FlexLocks