brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From geomacy <...@git.apache.org>
Subject [GitHub] brooklyn-server pull request #645: Persist OSGi bundles
Date Thu, 27 Apr 2017 11:39:16 GMT
Github user geomacy commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/645#discussion_r113662071
  
    --- Diff: core/src/main/java/org/apache/brooklyn/core/mgmt/persist/StoreObjectAccessorLocking.java
---
    @@ -146,6 +148,28 @@ public void put(String val) {
         }
         
         @Override
    +    public void put(ByteSource val) {
    --- End diff --
    
    This is basically a duplicate of the method above it, is it worth doing
    ```
        @Override
        public void put(final String val) {
            put(new Runnable() {
                @Override
                public void run() {
                    delegate.put(val);
                }
            });
        }
    
        @Override
        public void put(final ByteSource val) {
            put(new Runnable() {
                @Override
                public void run() {
                    delegate.put(val);
                }
            });
        }
        
        private void put(Runnable runnable) {
            try {
                queuedWriters.add(Thread.currentThread());
                lock.writeLock().lockInterruptibly();
                try {
                    queuedWriters.remove(Thread.currentThread());
                    if (hasScheduledPutOrDeleteWithNoRead())
                        // don't bother writing if someone will write after us and no one
is reading
                        return;
                    runnable.run();
    
                } finally {
                    lock.writeLock().unlock();
                }
            } catch (InterruptedException e) {
                throw Exceptions.propagate(e);
            } finally {
                queuedWriters.remove(Thread.currentThread());
            }
        }
    ```


---
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