curator-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Randgalt <...@git.apache.org>
Subject [GitHub] curator pull request: CURATOR-151: SharedValue/SharedCount API upd...
Date Thu, 09 Oct 2014 00:48:27 GMT
Github user Randgalt commented on a diff in the pull request:

    https://github.com/apache/curator/pull/47#discussion_r18621853
  
    --- Diff: curator-recipes/src/main/java/org/apache/curator/framework/recipes/shared/SharedValue.java
---
    @@ -184,6 +178,25 @@ public boolean trySetValue(VersionedValue<byte[]> newValue)
throws Exception
             return false;
         }
     
    +    private void updateValue(int version, byte[] bytes)
    +    {
    +        while (true)
    +        {
    +            VersionedValue<byte[]> current = currentValue.get();
    +            if (current.getVersion() >= version)
    +            {
    +                // A newer version was concurrently set.
    +                return;
    +            }
    +            if ( currentValue.compareAndSet(current, new VersionedValue<byte[]>(version,
bytes)) )
    +            {
    +                // Successfully set.
    +                return;
    +            }
    +            // Lost a race, retry.
    +        }
    +    }
    +
         /**
    --- End diff --
    
    This is the new behavior as I see it. It loops until it successfully updates the value.
Right?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message