[PATCH 3 of 4 V2] chgcache: implement the background preloading thread

Yuya Nishihara yuya at tcha.org
Tue Feb 28 09:17:01 EST 2017


On Mon, 27 Feb 2017 09:47:21 -0800, Jun Wu wrote:
> Excerpts from Yuya Nishihara's message of 2017-02-28 01:02:23 +0900:
> > On Wed, 22 Feb 2017 18:16:10 -0800, Jun Wu wrote:
> > > # HG changeset patch
> > > # User Jun Wu <quark at fb.com>
> > > # Date 1487813979 28800
> > > #      Wed Feb 22 17:39:39 2017 -0800
> > > # Node ID 28571825744fb4f4b424385f55afa9484532ef43
> > > # Parent  630457e88fa0485bce7822345ea640b5cdcb9b8e
> > > # Available At https://bitbucket.org/quark-zju/hg-draft 
> > > #              hg pull https://bitbucket.org/quark-zju/hg-draft  -r 28571825744f
> > > chgcache: implement the background preloading thread

> > > +    def stop(self):
> > > +        if self._thread is None:
> > > +            return
> > > +        self._shouldexit.set()
> > > +        self._ipc.send('') # unblock (possibly blocking) recv()
> > 
> > Ok, that will work though I'm not a fan of it.
> > 
> > Perhaps a cleaner way is to move recv() to the main loop of the server,
> > and deliver received messages via thread-safe queue + event. But that will
> > need more codes.
> 
> That sounds over complicated. Maybe shm is a better approach (no atime
> needed, no blocking / close issues, need extra code to write "atomically"
> but that's not hard)

Yeah, not simple, but I think that is an old-school way of writing a network
application.

Anyway, I'm not saying we should do that. Let's starts with a simpler code
(e.g. not stopping the thread at exit), if we are not going to handle
resources carefully. And that should be okay here. It's just chg.

OTOH, we'll need to design localrepo stuff in a higher level since it's an
important module and will be touched by more people who don't know chg.


More information about the Mercurial-devel mailing list