View Javadoc
1   /*
2    * Copyright 2017 The Netty Project
3    *
4    * The Netty Project licenses this file to you under the Apache License,
5    * version 2.0 (the "License"); you may not use this file except in compliance
6    * with the License. You may obtain a copy of the License at:
7    *
8    *   https://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13   * License for the specific language governing permissions and limitations
14   * under the License.
15   */
16  package io.netty5.channel.nio;
17  
18  import java.io.IOException;
19  import java.nio.channels.SelectionKey;
20  import java.nio.channels.Selector;
21  import java.nio.channels.spi.SelectorProvider;
22  import java.util.Set;
23  
24  final class SelectedSelectionKeySetSelector extends Selector {
25      private final SelectedSelectionKeySet selectionKeys;
26      private final Selector delegate;
27  
28      SelectedSelectionKeySetSelector(Selector delegate, SelectedSelectionKeySet selectionKeys) {
29          this.delegate = delegate;
30          this.selectionKeys = selectionKeys;
31      }
32  
33      @Override
34      public boolean isOpen() {
35          return delegate.isOpen();
36      }
37  
38      @Override
39      public SelectorProvider provider() {
40          return delegate.provider();
41      }
42  
43      @Override
44      public Set<SelectionKey> keys() {
45          return delegate.keys();
46      }
47  
48      @Override
49      public Set<SelectionKey> selectedKeys() {
50          return delegate.selectedKeys();
51      }
52  
53      @Override
54      public int selectNow() throws IOException {
55          selectionKeys.reset();
56          return delegate.selectNow();
57      }
58  
59      @Override
60      public int select(long timeout) throws IOException {
61          selectionKeys.reset();
62          return delegate.select(timeout);
63      }
64  
65      @Override
66      public int select() throws IOException {
67          selectionKeys.reset();
68          return delegate.select();
69      }
70  
71      @Override
72      public Selector wakeup() {
73          return delegate.wakeup();
74      }
75  
76      @Override
77      public void close() throws IOException {
78          delegate.close();
79      }
80  }