activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From michaelandrepearce <...@git.apache.org>
Subject [GitHub] activemq-artemis pull request #2328: ARTEMIS-2095 - Typed Properties ThreadS...
Date Tue, 25 Sep 2018 21:59:23 GMT
Github user michaelandrepearce commented on a diff in the pull request:

    https://github.com/apache/activemq-artemis/pull/2328#discussion_r220369450
  
    --- Diff: artemis-commons/src/main/java/org/apache/activemq/artemis/utils/collections/TypedProperties.java
---
    @@ -68,22 +73,23 @@ public TypedProperties() {
         *  Return the number of properties
         * */
        public int size() {
    -      return properties.size();
    +      return withReadLock(() -> properties.size());
        }
     
        public int getMemoryOffset() {
           // The estimate is basically the encode size + 2 object references for each entry
in the map
           // Note we don't include the attributes or anything else since they already included
in the memory estimate
           // of the ServerMessage
     
    -      return properties == null ? 0 : size + 2 * DataConstants.SIZE_INT * properties.size();
    +      return properties == null ? 0 : encodeSize + 2 * DataConstants.SIZE_INT * size();
        }
     
        public TypedProperties(final TypedProperties other) {
    -      synchronized (other) {
    +      other.withReadLock(() -> {
              properties = other.properties == null ? null : new HashMap<>(other.properties);
    -         size = other.size;
    -      }
    +         ENCODE_SIZE_FIELD_UPDATER.set(this, other.encodeSize);
    --- End diff --
    
    done.


---

Mime
View raw message