1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package io.netty.util.concurrent;
17
18 import java.util.Collections;
19 import java.util.Iterator;
20 import java.util.List;
21 import java.util.Set;
22 import java.util.concurrent.AbstractExecutorService;
23 import java.util.concurrent.Callable;
24 import java.util.concurrent.RunnableFuture;
25 import java.util.concurrent.TimeUnit;
26
27
28
29
30 public abstract class AbstractEventExecutor extends AbstractExecutorService implements EventExecutor {
31 private final Set<EventExecutor> executorSet = Collections.singleton((EventExecutor) this);
32
33 @Override
34 public EventExecutor next() {
35 return this;
36 }
37
38 @Override
39 public boolean inEventLoop() {
40 return inEventLoop(Thread.currentThread());
41 }
42
43 @Override
44 public Iterator<EventExecutor> iterator() {
45 return executorSet.iterator();
46 }
47
48 @Override
49 public Future<?> shutdownGracefully() {
50 return shutdownGracefully(2, 15, TimeUnit.SECONDS);
51 }
52
53
54
55
56 @Override
57 @Deprecated
58 public abstract void shutdown();
59
60
61
62
63 @Override
64 @Deprecated
65 public List<Runnable> shutdownNow() {
66 shutdown();
67 return Collections.emptyList();
68 }
69
70 @Override
71 public <V> Promise<V> newPromise() {
72 return new DefaultPromise<V>(this);
73 }
74
75 @Override
76 public <V> ProgressivePromise<V> newProgressivePromise() {
77 return new DefaultProgressivePromise<V>(this);
78 }
79
80 @Override
81 public <V> Future<V> newSucceededFuture(V result) {
82 return new SucceededFuture<V>(this, result);
83 }
84
85 @Override
86 public <V> Future<V> newFailedFuture(Throwable cause) {
87 return new FailedFuture<V>(this, cause);
88 }
89
90 @Override
91 public Future<?> submit(Runnable task) {
92 return (Future<?>) super.submit(task);
93 }
94
95 @Override
96 public <T> Future<T> submit(Runnable task, T result) {
97 return (Future<T>) super.submit(task, result);
98 }
99
100 @Override
101 public <T> Future<T> submit(Callable<T> task) {
102 return (Future<T>) super.submit(task);
103 }
104
105 @Override
106 protected final <T> RunnableFuture<T> newTaskFor(Runnable runnable, T value) {
107 return new PromiseTask<T>(this, runnable, value);
108 }
109
110 @Override
111 protected final <T> RunnableFuture<T> newTaskFor(Callable<T> callable) {
112 return new PromiseTask<T>(this, callable);
113 }
114
115 @Override
116 public ScheduledFuture<?> schedule(Runnable command, long delay,
117 TimeUnit unit) {
118 throw new UnsupportedOperationException();
119 }
120
121 @Override
122 public <V> ScheduledFuture<V> schedule(Callable<V> callable, long delay, TimeUnit unit) {
123 throw new UnsupportedOperationException();
124 }
125
126 @Override
127 public ScheduledFuture<?> scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit) {
128 throw new UnsupportedOperationException();
129 }
130
131 @Override
132 public ScheduledFuture<?> scheduleWithFixedDelay(Runnable command, long initialDelay, long delay, TimeUnit unit) {
133 throw new UnsupportedOperationException();
134 }
135 }