Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jgit-dev] Thread safety with fetch and read only operations

On Mon, Jul 1, 2013 at 6:10 PM, James Roper <james.roper@xxxxxxxxxxxx> wrote:
> I'm developing a site that serves the documentation for Play Framework from
> git, using jgit.  The idea is that all the docs, which are already in our
> git repo, will be served from the corresponding tags/branches etc, and we'll
> periodically (eg once an hour) fetch from GitHub, thus deployment of new
> versions and updates to snapshots etc all happen automatically.  I'll be
> doing the fetch with the same instance of jgit.  My question is, is it safe
> for reading threads to continue to read the repo while the fetch happens

This is safe.

> , or
> do I need to block the reading threads while the fetch happens?

Unnecessary.

> Also, are there any other thread safety, resource or concurrency concerns
> with having a single repository serving many concurrent requests?  The only
> shared object is the Repository,

This type is thread-safe in the local filesystem (aka default) storage system.

> each request creates and disposes/releases
> its own RevWalk/TreeWalk instances.

RIght, RevWalk and TreeWalk are not thread-safe.

>  Is it possible for readcoing threads
> using a single Repository to block each other or interfere with each other
> in some way?

No. There are very few locks in this section of code. We use a lot of
AtomicReference types to make things lockless.


Back to the top