Rename TaskScheduler to ChannelTaskScheduler

This commit is contained in:
Trustin Lee 2012-08-19 15:10:09 +09:00
parent f02ce0fdca
commit 8bfbebc772
14 changed files with 27 additions and 27 deletions

View File

@ -31,10 +31,10 @@ import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
public final class TaskScheduler {
public final class ChannelTaskScheduler {
private static final InternalLogger logger =
InternalLoggerFactory.getInstance(TaskScheduler.class);
InternalLoggerFactory.getInstance(ChannelTaskScheduler.class);
private static final long SCHEDULE_PURGE_INTERVAL = TimeUnit.SECONDS.toNanos(1);
private static final long START_TIME = System.nanoTime();
@ -55,7 +55,7 @@ public final class TaskScheduler {
/** 0 - not started, 1 - started, 2 - shut down, 3 - terminated */
private volatile int state;
public TaskScheduler(ThreadFactory threadFactory) {
public ChannelTaskScheduler(ThreadFactory threadFactory) {
if (threadFactory == null) {
throw new NullPointerException("threadFactory");
}

View File

@ -20,7 +20,7 @@ import java.util.concurrent.ThreadFactory;
class DefaultEventExecutor extends SingleThreadEventExecutor {
DefaultEventExecutor(
DefaultEventExecutorGroup parent, ThreadFactory threadFactory, TaskScheduler scheduler) {
DefaultEventExecutorGroup parent, ThreadFactory threadFactory, ChannelTaskScheduler scheduler) {
super(parent, threadFactory, scheduler);
}

View File

@ -29,7 +29,7 @@ public class DefaultEventExecutorGroup extends MultithreadEventExecutorGroup {
@Override
protected EventExecutor newChild(
ThreadFactory threadFactory, TaskScheduler scheduler, Object... args) throws Exception {
ThreadFactory threadFactory, ChannelTaskScheduler scheduler, Object... args) throws Exception {
return new DefaultEventExecutor(this, threadFactory, scheduler);
}
}

View File

@ -24,7 +24,7 @@ public abstract class MultithreadEventExecutorGroup implements EventExecutorGrou
private static final int DEFAULT_POOL_SIZE = Runtime.getRuntime().availableProcessors() * 2;
private static final AtomicInteger poolId = new AtomicInteger();
final TaskScheduler scheduler;
final ChannelTaskScheduler scheduler;
private final EventExecutor[] children;
private final AtomicInteger childIndex = new AtomicInteger();
@ -41,7 +41,7 @@ public abstract class MultithreadEventExecutorGroup implements EventExecutorGrou
threadFactory = new DefaultThreadFactory();
}
scheduler = new TaskScheduler(threadFactory);
scheduler = new ChannelTaskScheduler(threadFactory);
children = new SingleThreadEventExecutor[nThreads];
for (int i = 0; i < nThreads; i ++) {
@ -67,7 +67,7 @@ public abstract class MultithreadEventExecutorGroup implements EventExecutorGrou
}
protected abstract EventExecutor newChild(
ThreadFactory threadFactory, TaskScheduler scheduler, Object... args) throws Exception;
ThreadFactory threadFactory, ChannelTaskScheduler scheduler, Object... args) throws Exception;
@Override
public void shutdown() {

View File

@ -51,13 +51,13 @@ public abstract class SingleThreadEventExecutor extends AbstractExecutorService
private final Thread thread;
private final Object stateLock = new Object();
private final Semaphore threadLock = new Semaphore(0);
private final TaskScheduler scheduler;
private final ChannelTaskScheduler scheduler;
private final Set<Runnable> shutdownHooks = new LinkedHashSet<Runnable>();
/** 0 - not started, 1 - started, 2 - shut down, 3 - terminated */
private volatile int state;
protected SingleThreadEventExecutor(
EventExecutorGroup parent, ThreadFactory threadFactory, TaskScheduler scheduler) {
EventExecutorGroup parent, ThreadFactory threadFactory, ChannelTaskScheduler scheduler) {
if (threadFactory == null) {
throw new NullPointerException("threadFactory");
}

View File

@ -20,7 +20,7 @@ import java.util.concurrent.ThreadFactory;
public abstract class SingleThreadEventLoop extends SingleThreadEventExecutor implements EventLoop {
protected SingleThreadEventLoop(
EventLoopGroup parent, ThreadFactory threadFactory, TaskScheduler scheduler) {
EventLoopGroup parent, ThreadFactory threadFactory, ChannelTaskScheduler scheduler) {
super(parent, threadFactory, scheduler);
}

View File

@ -16,14 +16,14 @@
package io.netty.channel.local;
import io.netty.channel.SingleThreadEventLoop;
import io.netty.channel.TaskScheduler;
import io.netty.channel.ChannelTaskScheduler;
import java.util.concurrent.ThreadFactory;
final class LocalEventLoop extends SingleThreadEventLoop {
LocalEventLoop(
LocalEventLoopGroup parent, ThreadFactory threadFactory, TaskScheduler scheduler) {
LocalEventLoopGroup parent, ThreadFactory threadFactory, ChannelTaskScheduler scheduler) {
super(parent, threadFactory, scheduler);
}

View File

@ -17,7 +17,7 @@ package io.netty.channel.local;
import io.netty.channel.EventExecutor;
import io.netty.channel.MultithreadEventLoopGroup;
import io.netty.channel.TaskScheduler;
import io.netty.channel.ChannelTaskScheduler;
import java.util.concurrent.ThreadFactory;
@ -37,7 +37,7 @@ public class LocalEventLoopGroup extends MultithreadEventLoopGroup {
@Override
protected EventExecutor newChild(
ThreadFactory threadFactory, TaskScheduler scheduler, Object... args) throws Exception {
ThreadFactory threadFactory, ChannelTaskScheduler scheduler, Object... args) throws Exception {
return new LocalEventLoop(this, threadFactory, scheduler);
}
}

View File

@ -16,13 +16,13 @@
package io.netty.channel.socket.aio;
import io.netty.channel.SingleThreadEventLoop;
import io.netty.channel.TaskScheduler;
import io.netty.channel.ChannelTaskScheduler;
import java.util.concurrent.ThreadFactory;
final class AioEventLoop extends SingleThreadEventLoop {
AioEventLoop(AioEventLoopGroup parent, ThreadFactory threadFactory, TaskScheduler scheduler) {
AioEventLoop(AioEventLoopGroup parent, ThreadFactory threadFactory, ChannelTaskScheduler scheduler) {
super(parent, threadFactory, scheduler);
}

View File

@ -18,7 +18,7 @@ package io.netty.channel.socket.aio;
import io.netty.channel.EventExecutor;
import io.netty.channel.EventLoopException;
import io.netty.channel.MultithreadEventLoopGroup;
import io.netty.channel.TaskScheduler;
import io.netty.channel.ChannelTaskScheduler;
import java.io.IOException;
import java.lang.reflect.Field;
@ -59,7 +59,7 @@ public class AioEventLoopGroup extends MultithreadEventLoopGroup {
@Override
protected EventExecutor newChild(
ThreadFactory threadFactory, TaskScheduler scheduler, Object... args) throws Exception {
ThreadFactory threadFactory, ChannelTaskScheduler scheduler, Object... args) throws Exception {
return new AioEventLoop(this, threadFactory, scheduler);
}

View File

@ -18,7 +18,7 @@ package io.netty.channel.socket.nio;
import io.netty.channel.Channel;
import io.netty.channel.ChannelException;
import io.netty.channel.SingleThreadEventLoop;
import io.netty.channel.TaskScheduler;
import io.netty.channel.ChannelTaskScheduler;
import io.netty.channel.socket.nio.AbstractNioChannel.NioUnsafe;
import io.netty.logging.InternalLogger;
import io.netty.logging.InternalLoggerFactory;
@ -65,7 +65,7 @@ final class NioEventLoop extends SingleThreadEventLoop {
NioEventLoop(
NioEventLoopGroup parent, ThreadFactory threadFactory,
TaskScheduler scheduler, SelectorProvider selectorProvider) {
ChannelTaskScheduler scheduler, SelectorProvider selectorProvider) {
super(parent, threadFactory, scheduler);
if (selectorProvider == null) {
throw new NullPointerException("selectorProvider");

View File

@ -17,7 +17,7 @@ package io.netty.channel.socket.nio;
import io.netty.channel.EventExecutor;
import io.netty.channel.MultithreadEventLoopGroup;
import io.netty.channel.TaskScheduler;
import io.netty.channel.ChannelTaskScheduler;
import java.nio.channels.spi.SelectorProvider;
import java.util.concurrent.ThreadFactory;
@ -43,7 +43,7 @@ public class NioEventLoopGroup extends MultithreadEventLoopGroup {
@Override
protected EventExecutor newChild(
ThreadFactory threadFactory, TaskScheduler scheduler, Object... args) throws Exception {
ThreadFactory threadFactory, ChannelTaskScheduler scheduler, Object... args) throws Exception {
SelectorProvider selectorProvider;
if (args == null || args.length == 0 || args[0] == null) {
selectorProvider = SelectorProvider.provider();

View File

@ -21,7 +21,7 @@ import io.netty.channel.ChannelException;
import io.netty.channel.ChannelFuture;
import io.netty.channel.EventLoop;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.TaskScheduler;
import io.netty.channel.ChannelTaskScheduler;
import java.util.Collections;
import java.util.Queue;
@ -35,7 +35,7 @@ import java.util.concurrent.TimeUnit;
public class OioEventLoopGroup implements EventLoopGroup {
private final int maxChannels;
final TaskScheduler scheduler;
final ChannelTaskScheduler scheduler;
final ThreadFactory threadFactory;
final Set<OioEventLoop> activeChildren = Collections.newSetFromMap(
new ConcurrentHashMap<OioEventLoop, Boolean>());
@ -62,7 +62,7 @@ public class OioEventLoopGroup implements EventLoopGroup {
this.maxChannels = maxChannels;
this.threadFactory = threadFactory;
scheduler = new TaskScheduler(threadFactory);
scheduler = new ChannelTaskScheduler(threadFactory);
tooManyChannels = new ChannelException("too many channels (max: " + maxChannels + ')');
tooManyChannels.setStackTrace(new StackTraceElement[0]);

View File

@ -257,7 +257,7 @@ public class SingleThreadEventLoopTest {
SingleThreadEventLoopImpl() {
super(null, Executors.defaultThreadFactory(),
new TaskScheduler(Executors.defaultThreadFactory()));
new ChannelTaskScheduler(Executors.defaultThreadFactory()));
}
@Override