Interesting point. At the moment if your Iterable elements aren't unique by
equality then you'll deadlock yourself (unless some kind thread comes along
and remove something equal to the duplicated item). Perhaps the interface
should take Set rather than Iterable?
On 29 Aug 2013 18:27, "oli-hall" <notifications@github.com> wrote:

> In src/main/java/org/atlasapi/util/GroupLock.java:
>
> > +    public boolean tryLock(Iterable<T> ids) throws InterruptedException {
> > +        synchronized (locked) {
> > +            List<T> orderedIds = ordering.sortedCopy(ids);
> > +            for (T id : orderedIds) {
> > +                if (!tryLock(id)) {
> > +                    unlockTill(orderedIds, id);
> > +                    return false;
> > +                }
> > +            }
> > +            return true;
> > +        }
> > +    }
> > +
> > +    private void unlockTill(List<T> orderedIds, T limit) {
> > +        for (T id : orderedIds) {
> > +            if (id == limit) {
>
> I wasn't necessarily saying that one wouldn't want reference equality. I
> was just vaguely wondering about scenarios such as the iterable containing
> multiple identical instances of T (i.e. A.equals(B) is true, but A == B is
> not).
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/atlasapi/atlas-model/pull/145/files#r6067116>
> .
>