Github user michaelandrepearce commented on a diff in the pull request:
https://github.com/apache/activemq-artemis/pull/2175#discussion_r205174465
--- Diff:
artemis-commons/src/main/java/org/apache/activemq/artemis/utils/AtomicBooleanFieldUpdater.java
---
@@ -0,0 +1,154 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.artemis.utils;
+
+import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
+import sun.reflect.CallerSensitive;
+
+public class AtomicBooleanFieldUpdater<T> {
+
+ /**
+ * Creates and returns an updater for objects with the given field.
+ * The Class argument is needed to check that reflective types and
+ * generic types match.
+ *
+ * @param tclass the class of the objects holding the field
+ * @param fieldName the name of the field to be updated
+ * @param <U> the type of instances of tclass
+ * @return the updater
+ * @throws IllegalArgumentException if the field is not a
+ * volatile long type
+ * @throws RuntimeException with a nested reflection-based
+ * exception if the class does not hold field or is the wrong type,
+ * or the field is inaccessible to the caller according to Java language
+ * access control
+ */
+ @CallerSensitive
+ public static <U> AtomicBooleanFieldUpdater<U> newUpdater(Class<U>
tclass, String fieldName) {
--- End diff --
@franz1981 using Boolean you might as well then just use atomic boolean,
which you commented eadlier on and rightly so to use atomic updater. As the
point is to save having object reference overheads.
The point of the class is just to make it reusable if else where you want
else you end up with lots of dupe code just for all the int to bool logic.
---