From caff7c941b1db5ef1d143fce78b71da603dbf6a1 Mon Sep 17 00:00:00 2001 From: Norman Maurer Date: Tue, 6 Mar 2012 19:31:47 +0100 Subject: [PATCH] Checkstyle fixes --- .../socket/nio/AbstractWorkerPool.java | 83 ------------------- .../socket/nio/NioDatagramWorkerPool.java | 2 +- .../channel/socket/nio/NioWorkerPool.java | 2 +- .../socket/nio/ShareableWorkerPool.java | 2 +- 4 files changed, 3 insertions(+), 86 deletions(-) delete mode 100644 transport/src/main/java/io/netty/channel/socket/nio/AbstractWorkerPool.java diff --git a/transport/src/main/java/io/netty/channel/socket/nio/AbstractWorkerPool.java b/transport/src/main/java/io/netty/channel/socket/nio/AbstractWorkerPool.java deleted file mode 100644 index 39b5556703..0000000000 --- a/transport/src/main/java/io/netty/channel/socket/nio/AbstractWorkerPool.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright 2011 The Netty Project - * - * The Netty Project 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 io.netty.channel.socket.nio; - -import io.netty.channel.Channel; -import io.netty.channel.socket.Worker; -import io.netty.util.ExternalResourceReleasable; -import io.netty.util.internal.ExecutorUtil; - -import java.util.concurrent.Executor; -import java.util.concurrent.atomic.AtomicInteger; - -/** - * Abstract base class for {@link WorkerPool} implementations that create the {@link Worker}'s up-front and return them in a "fair" fashion when calling - * {@link #nextWorker()} - * - */ -public abstract class AbstractWorkerPool implements WorkerPool , ExternalResourceReleasable{ - - private final AbstractNioWorker[] workers; - private final AtomicInteger workerIndex = new AtomicInteger(); - private final Executor workerExecutor; - - /** - * Create a new instance - * - * @param workerExecutor the {@link Executor} to use for the {@link Worker}'s - * @param allowShutdownOnIdle allow the {@link Worker}'s to shutdown when there is not {@link Channel} is registered with it - * @param workerCount the count of {@link Worker}'s to create - */ - AbstractWorkerPool(Executor workerExecutor, int workerCount, boolean allowShutDownOnIdle) { - if (workerExecutor == null) { - throw new NullPointerException("workerExecutor"); - } - if (workerCount <= 0) { - throw new IllegalArgumentException( - "workerCount (" + workerCount + ") " + - "must be a positive integer."); - } - workers = new AbstractNioWorker[workerCount]; - - for (int i = 0; i < workers.length; i++) { - workers[i] = createWorker(workerExecutor, allowShutDownOnIdle); - } - this.workerExecutor = workerExecutor; - - } - - /** - * Create a new {@link Worker} which uses the given {@link Executor} to service IO - * - * - * @param executor the {@link Executor} to use - * @param allowShutdownOnIdle allow the {@link Worker} to shutdown when there is not {@link Channel} is registered with it - * @return worker the new {@link Worker} - */ - protected abstract E createWorker(Executor executor, boolean allowShutdownOnIdle); - - @SuppressWarnings("unchecked") - public E nextWorker() { - return (E) workers[Math.abs(workerIndex.getAndIncrement() % workers.length)]; - } - - @Override - public void releaseExternalResources() { - ExecutorUtil.terminate(workerExecutor); - } - -} diff --git a/transport/src/main/java/io/netty/channel/socket/nio/NioDatagramWorkerPool.java b/transport/src/main/java/io/netty/channel/socket/nio/NioDatagramWorkerPool.java index 938c898b77..16f881fc63 100644 --- a/transport/src/main/java/io/netty/channel/socket/nio/NioDatagramWorkerPool.java +++ b/transport/src/main/java/io/netty/channel/socket/nio/NioDatagramWorkerPool.java @@ -23,7 +23,7 @@ import java.util.concurrent.Executor; * * */ -public class NioDatagramWorkerPool extends AbstractWorkerPool{ +public class NioDatagramWorkerPool extends AbstractNioWorkerPool { protected NioDatagramWorkerPool(Executor executor, int workerCount, boolean allowShutdownOnIdle) { super(executor, workerCount, allowShutdownOnIdle); diff --git a/transport/src/main/java/io/netty/channel/socket/nio/NioWorkerPool.java b/transport/src/main/java/io/netty/channel/socket/nio/NioWorkerPool.java index cf124080ea..4d474799c7 100644 --- a/transport/src/main/java/io/netty/channel/socket/nio/NioWorkerPool.java +++ b/transport/src/main/java/io/netty/channel/socket/nio/NioWorkerPool.java @@ -23,7 +23,7 @@ import java.util.concurrent.Executor; * * */ -public class NioWorkerPool extends AbstractWorkerPool{ +public class NioWorkerPool extends AbstractNioWorkerPool { NioWorkerPool(Executor executor, int workerCount, boolean allowShutdownOnIdle) { super(executor, workerCount, allowShutdownOnIdle); diff --git a/transport/src/main/java/io/netty/channel/socket/nio/ShareableWorkerPool.java b/transport/src/main/java/io/netty/channel/socket/nio/ShareableWorkerPool.java index 2c856cd562..c3fb95b89e 100644 --- a/transport/src/main/java/io/netty/channel/socket/nio/ShareableWorkerPool.java +++ b/transport/src/main/java/io/netty/channel/socket/nio/ShareableWorkerPool.java @@ -24,7 +24,7 @@ import io.netty.util.ExternalResourceReleasable; * * */ -public final class ShareableWorkerPool implements WorkerPool{ +public final class ShareableWorkerPool implements WorkerPool { private final WorkerPool wrapped;