12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package sun.nio.ch;
27
28 import java.nio.channels.*;
29 import java.nio.channels.spi.AsynchronousChannelProvider;
30 import java.util.concurrent.ExecutorService;
31 import java.util.concurrent.ThreadFactory;
32 import java.net.ProtocolFamily;
33 import java.io.IOException;
34
35 public class LinuxAsynchronousChannelProvider
36 extends AsynchronousChannelProvider
37 {
38 private static volatile EPollPort defaultPort;
39
40 private EPollPort defaultEventPort() throws IOException {
41 if (defaultPort == null) {
42 synchronized (LinuxAsynchronousChannelProvider.class) {
43 if (defaultPort == null) {
44 defaultPort = new EPollPort(this, ThreadPool.getDefault()).start();
45 }
46 }
47 }
48 return defaultPort;
49 }
50
51 public LinuxAsynchronousChannelProvider() {
52 }
71 } else {
72 if (!(group instanceof EPollPort))
73 throw new IllegalChannelGroupException();
74 return (Port)group;
75 }
76 }
77
78 @Override
79 public AsynchronousServerSocketChannel openAsynchronousServerSocketChannel(AsynchronousChannelGroup group)
80 throws IOException
81 {
82 return new UnixAsynchronousServerSocketChannelImpl(toPort(group));
83 }
84
85 @Override
86 public AsynchronousSocketChannel openAsynchronousSocketChannel(AsynchronousChannelGroup group)
87 throws IOException
88 {
89 return new UnixAsynchronousSocketChannelImpl(toPort(group));
90 }
91
92 @Override
93 public AsynchronousDatagramChannel openAsynchronousDatagramChannel(ProtocolFamily family,
94 AsynchronousChannelGroup group)
95 throws IOException
96 {
97 return new SimpleAsynchronousDatagramChannelImpl(family, toPort(group));
98 }
99 }
|
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package sun.nio.ch;
27
28 import java.nio.channels.*;
29 import java.nio.channels.spi.AsynchronousChannelProvider;
30 import java.util.concurrent.ExecutorService;
31 import java.util.concurrent.ThreadFactory;
32 import java.io.IOException;
33
34 public class LinuxAsynchronousChannelProvider
35 extends AsynchronousChannelProvider
36 {
37 private static volatile EPollPort defaultPort;
38
39 private EPollPort defaultEventPort() throws IOException {
40 if (defaultPort == null) {
41 synchronized (LinuxAsynchronousChannelProvider.class) {
42 if (defaultPort == null) {
43 defaultPort = new EPollPort(this, ThreadPool.getDefault()).start();
44 }
45 }
46 }
47 return defaultPort;
48 }
49
50 public LinuxAsynchronousChannelProvider() {
51 }
70 } else {
71 if (!(group instanceof EPollPort))
72 throw new IllegalChannelGroupException();
73 return (Port)group;
74 }
75 }
76
77 @Override
78 public AsynchronousServerSocketChannel openAsynchronousServerSocketChannel(AsynchronousChannelGroup group)
79 throws IOException
80 {
81 return new UnixAsynchronousServerSocketChannelImpl(toPort(group));
82 }
83
84 @Override
85 public AsynchronousSocketChannel openAsynchronousSocketChannel(AsynchronousChannelGroup group)
86 throws IOException
87 {
88 return new UnixAsynchronousSocketChannelImpl(toPort(group));
89 }
90 }
|