Code Review
/
yangtools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Address trivial eclipse warnings
[yangtools.git]
/
common
/
util
/
src
/
main
/
java
/
org
/
opendaylight
/
yangtools
/
util
/
concurrent
/
CountingRejectedExecutionHandler.java
diff --git
a/common/util/src/main/java/org/opendaylight/yangtools/util/concurrent/CountingRejectedExecutionHandler.java
b/common/util/src/main/java/org/opendaylight/yangtools/util/concurrent/CountingRejectedExecutionHandler.java
index c44864350e863dc639e307d23fc343efbc38bfc1..8fd45dc310ac0bafc80fce37a3b1f675f8bba182 100644
(file)
--- a/
common/util/src/main/java/org/opendaylight/yangtools/util/concurrent/CountingRejectedExecutionHandler.java
+++ b/
common/util/src/main/java/org/opendaylight/yangtools/util/concurrent/CountingRejectedExecutionHandler.java
@@
-9,11
+9,9
@@
package org.opendaylight.yangtools.util.concurrent;
import com.google.common.base.Preconditions;
package org.opendaylight.yangtools.util.concurrent;
import com.google.common.base.Preconditions;
-
import java.util.concurrent.RejectedExecutionHandler;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.RejectedExecutionHandler;
import java.util.concurrent.ThreadPoolExecutor;
-import java.util.concurrent.atomic.AtomicLongFieldUpdater;
-
+import java.util.concurrent.atomic.LongAdder;
import org.opendaylight.yangtools.util.ExecutorServiceUtil;
/**
import org.opendaylight.yangtools.util.ExecutorServiceUtil;
/**
@@
-23,10
+21,8
@@
import org.opendaylight.yangtools.util.ExecutorServiceUtil;
* @author Thomas Pantelis
*/
public class CountingRejectedExecutionHandler implements RejectedExecutionHandler {
* @author Thomas Pantelis
*/
public class CountingRejectedExecutionHandler implements RejectedExecutionHandler {
- private static final AtomicLongFieldUpdater<CountingRejectedExecutionHandler> COUNTER_UPDATER =
- AtomicLongFieldUpdater.newUpdater(CountingRejectedExecutionHandler.class, "rejectedTaskCounter");
+ private final LongAdder rejectedTaskCounter = new LongAdder();
private final RejectedExecutionHandler delegate;
private final RejectedExecutionHandler delegate;
- private volatile long rejectedTaskCounter;
/**
* Constructor.
/**
* Constructor.
@@
-39,15
+35,15
@@
public class CountingRejectedExecutionHandler implements RejectedExecutionHandle
@Override
public void rejectedExecution( final Runnable task, final ThreadPoolExecutor executor ) {
@Override
public void rejectedExecution( final Runnable task, final ThreadPoolExecutor executor ) {
-
COUNTER_UPDATER.incrementAndGet(this
);
- delegate.rejectedExecution(
task, executor
);
+
rejectedTaskCounter.increment(
);
+ delegate.rejectedExecution(
task, executor
);
}
/**
* Returns the rejected task count.
*/
public long getRejectedTaskCount() {
}
/**
* Returns the rejected task count.
*/
public long getRejectedTaskCount() {
- return rejectedTaskCounter;
+ return rejectedTaskCounter
.sum()
;
}
/**
}
/**
@@
-56,14
+52,14
@@
public class CountingRejectedExecutionHandler implements RejectedExecutionHandle
* the task is discarded.
*/
public static CountingRejectedExecutionHandler newCallerRunsPolicy() {
* the task is discarded.
*/
public static CountingRejectedExecutionHandler newCallerRunsPolicy() {
- return new CountingRejectedExecutionHandler(
new ThreadPoolExecutor.CallerRunsPolicy()
);
+ return new CountingRejectedExecutionHandler(
new ThreadPoolExecutor.CallerRunsPolicy()
);
}
/**
* Returns a counting handler for rejected tasks that throws a RejectedExecutionException.
*/
public static CountingRejectedExecutionHandler newAbortPolicy() {
}
/**
* Returns a counting handler for rejected tasks that throws a RejectedExecutionException.
*/
public static CountingRejectedExecutionHandler newAbortPolicy() {
- return new CountingRejectedExecutionHandler(
new ThreadPoolExecutor.AbortPolicy()
);
+ return new CountingRejectedExecutionHandler(
new ThreadPoolExecutor.AbortPolicy()
);
}
/**
}
/**
@@
-71,6
+67,6
@@
public class CountingRejectedExecutionHandler implements RejectedExecutionHandle
* {@link ThreadPoolExecutor}'s backing queue until it can add the task to the queue.
*/
public static CountingRejectedExecutionHandler newCallerWaitsPolicy() {
* {@link ThreadPoolExecutor}'s backing queue until it can add the task to the queue.
*/
public static CountingRejectedExecutionHandler newCallerWaitsPolicy() {
- return new CountingRejectedExecutionHandler(
ExecutorServiceUtil.waitInQueueExecutionHandler()
);
+ return new CountingRejectedExecutionHandler(
ExecutorServiceUtil.waitInQueueExecutionHandler()
);
}
}
}
}