Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/java.base/aix/classes/sun/nio/ch/AixAsynchronousChannelProvider.java
41139 views
1
/*
2
* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
3
* Copyright (c) 2012 SAP SE. All rights reserved.
4
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5
*
6
* This code is free software; you can redistribute it and/or modify it
7
* under the terms of the GNU General Public License version 2 only, as
8
* published by the Free Software Foundation. Oracle designates this
9
* particular file as subject to the "Classpath" exception as provided
10
* by Oracle in the LICENSE file that accompanied this code.
11
*
12
* This code is distributed in the hope that it will be useful, but WITHOUT
13
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15
* version 2 for more details (a copy is included in the LICENSE file that
16
* accompanied this code).
17
*
18
* You should have received a copy of the GNU General Public License version
19
* 2 along with this work; if not, write to the Free Software Foundation,
20
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
21
*
22
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
23
* or visit www.oracle.com if you need additional information or have any
24
* questions.
25
*/
26
27
package sun.nio.ch;
28
29
import java.nio.channels.*;
30
import java.nio.channels.spi.AsynchronousChannelProvider;
31
import java.util.concurrent.ExecutorService;
32
import java.util.concurrent.ThreadFactory;
33
import java.io.IOException;
34
35
public class AixAsynchronousChannelProvider
36
extends AsynchronousChannelProvider
37
{
38
private static volatile AixPollPort defaultPort;
39
40
private AixPollPort defaultEventPort() throws IOException {
41
if (defaultPort == null) {
42
synchronized (AixAsynchronousChannelProvider.class) {
43
if (defaultPort == null) {
44
defaultPort = new AixPollPort(this, ThreadPool.getDefault()).start();
45
}
46
}
47
}
48
return defaultPort;
49
}
50
51
public AixAsynchronousChannelProvider() {
52
}
53
54
@Override
55
public AsynchronousChannelGroup openAsynchronousChannelGroup(int nThreads, ThreadFactory factory)
56
throws IOException
57
{
58
return new AixPollPort(this, ThreadPool.create(nThreads, factory)).start();
59
}
60
61
@Override
62
public AsynchronousChannelGroup openAsynchronousChannelGroup(ExecutorService executor, int initialSize)
63
throws IOException
64
{
65
return new AixPollPort(this, ThreadPool.wrap(executor, initialSize)).start();
66
}
67
68
private Port toPort(AsynchronousChannelGroup group) throws IOException {
69
if (group == null) {
70
return defaultEventPort();
71
} else {
72
if (!(group instanceof AixPollPort))
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
93