osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GitHub] activemq-artemis pull request #2328: ARTEMIS-2095 - Typed Properties ThreadS...


Github user franz1981 commented on a diff in the pull request:

    https://github.com/apache/activemq-artemis/pull/2328#discussion_r220179880
  
    --- Diff: artemis-commons/src/main/java/org/apache/activemq/artemis/utils/collections/TypedProperties.java ---
    @@ -1056,4 +1107,26 @@ public static void setObjectProperty(final SimpleString key, final Object value,
              throw new ActiveMQPropertyConversionException(value.getClass() + " is not a valid property type");
           }
        }
    +
    +
    +
    +   private <T> T withWriteLock(Supplier<T> supplier) {
    +      long lock = this.writeLock();
    +      try {
    +         return supplier.get();
    +      } finally {
    +         this.unlockWrite(lock);
    +      }
    +   }
    +
    +   private <T> T withReadLock(Supplier<T> supplier) {
    --- End diff --
    
    Not only...other primitive suppliers overloads as well to avoid creating garbage for simple ops...And the other thing is that..a supplier is a quite elegant solution i admit, but sadly the JVM tends to not being able to drop the lambda allocation out...So I suggest a less elegant but more robust "old school" way to do the same (ie without lambdas).
    Sorry for being direct on it, but I'm writing while doing 10000 other things, didn't want to be rude :(



---