Re: Regarding BGworkers - Mailing list pgsql-hackers

From Alvaro Herrera
Subject Re: Regarding BGworkers
Date
Msg-id 20130813145943.GA8742@eldon.alvh.no-ip.org
Whole thread Raw
In response to Re: Regarding BGworkers  (Robert Haas <robertmhaas@gmail.com>)
Responses Re: Regarding BGworkers
List pgsql-hackers
Robert Haas escribió:
> On Mon, Aug 5, 2013 at 9:20 PM, Michael Paquier
> <michael.paquier@gmail.com> wrote:
> > On Fri, Aug 2, 2013 at 1:40 PM, Alvaro Herrera <alvherre@2ndquadrant.com> wrote:
> >> That seems more mess than just keeping that function in postmaster.c.
> >> I agree with moving the other one.
> > Please find attached a patch for that can be applied on master branch.
> > do_start_bgworker is renamed to StartBackgroundWorker and moved to
> > bgworker.c. At the same time, bgworker_quickdie, bgworker_die and
> > bgworker_sigusr1_handler are moved to bgworker.c as they are used in
> > do_start_bgworker.
> 
> This particular formulation doesn't seem quite good to me, because
> we'd end up with a function called StartBackgroundWorker() and another
> called StartOneBackgroundWorker() doing related but different things.
> Maybe we can name things a bit better?

Yeah, we also have start_bgworker().  I agree that we should rename
things so that they make as much sense as possible.

In the current code, we have this:

StartOneBackgroundWorker()    in postmaster.c start_bgworker()        in postmaster.c   do_start_bgworker()        in
postmaster.c

With this patch we would have
StartOneBackgroundWorker()    in postmaster.c start_bgworker()        in postmaster.c   StartBackgroundWorker()    in
bgworker.c

I think we should rename to something like this:

maybe_start_bgworker()        in postmaster.c do_start_bgworker()        in postmaster.c   StartBackgroundWorker()
inbgworker.c
 

(I would also rename the functions in 9.3 to avoid inconsistency).  Not
wedded to those particular names, but (1) I would add the "maybe" prefix
because that's what that function does; and (2) it seems to me that
stuff in bgworker.c tend to use CamelCaseNaming and postmaster.c uses
names_with_stuffed_underscores.

(My convention tends to be that "internal" stuff uses underscores while
exposed APIs use CamelCase.  I probably fail to do it really
consistently.)

-- 
Álvaro Herrera                http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services



pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: Foreground vacuum and buffer access strategy
Next
From: Hannu Krosing
Date:
Subject: Re: How to create read-only view on 9.3