本文整理汇总了Java中libcore.io.IoUtils.setBlocking方法的典型用法代码示例。如果您正苦于以下问题:Java IoUtils.setBlocking方法的具体用法?Java IoUtils.setBlocking怎么用?Java IoUtils.setBlocking使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类libcore.io.IoUtils
的用法示例。
在下文中一共展示了IoUtils.setBlocking方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: SelectorImpl
import libcore.io.IoUtils; //导入方法依赖的package包/类
public SelectorImpl(SelectorProvider selectorProvider) throws IOException {
super(selectorProvider);
/*
* Create a pipe to trigger wakeup. We can't use a NIO pipe because it
* would be closed if the selecting thread is interrupted. Also
* configure the pipe so we can fully drain it without blocking.
*/
try {
FileDescriptor[] pipeFds = Libcore.os.pipe();
wakeupIn = pipeFds[0];
wakeupOut = pipeFds[1];
IoUtils.setBlocking(wakeupIn, false);
pollFds.add(new StructPollfd());
setPollFd(0, wakeupIn, POLLIN, null);
} catch (ErrnoException errnoException) {
throw errnoException.rethrowAsIOException();
}
}
示例2: implConfigureBlocking
import libcore.io.IoUtils; //导入方法依赖的package包/类
@Override protected void implConfigureBlocking(boolean blocking) throws IOException {
IoUtils.setBlocking(fd, blocking);
}
示例3: implConfigureBlocking
import libcore.io.IoUtils; //导入方法依赖的package包/类
@Override protected void implConfigureBlocking(boolean blocking) throws IOException {
IoUtils.setBlocking(socket.getFD$(), blocking);
}
示例4: implConfigureBlocking
import libcore.io.IoUtils; //导入方法依赖的package包/类
@Override protected void implConfigureBlocking(boolean blocking) throws IOException {
IoUtils.setBlocking(getFD(), blocking);
}
示例5: connect
import libcore.io.IoUtils; //导入方法依赖的package包/类
@Override
public boolean connect(SocketAddress socketAddress) throws IOException {
// status must be open and unconnected
checkUnconnected();
// check the address
InetSocketAddress inetSocketAddress = validateAddress(socketAddress);
InetAddress normalAddr = inetSocketAddress.getAddress();
// When connecting, map ANY address to Localhost
if (normalAddr.isAnyLocalAddress()) {
normalAddr = InetAddress.getLocalHost();
}
int port = inetSocketAddress.getPort();
String hostName = normalAddr.getHostName();
// security check
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkConnect(hostName, port);
}
// connect result
int result = EOF;
boolean finished = false;
try {
if (isBlocking()) {
begin();
networkSystem.connect(fd, normalAddr, port, 0);
finished = true; // Or we'd have thrown an exception.
} else {
finished = networkSystem.connectNonBlocking(fd, normalAddr, port);
// set back to nonblocking to work around with a bug in portlib
if (!isBlocking()) {
IoUtils.setBlocking(fd, false);
}
}
isBound = finished;
} catch (IOException e) {
if (e instanceof ConnectException && !isBlocking()) {
status = SOCKET_STATUS_PENDING;
} else {
if (isOpen()) {
close();
finished = true;
}
throw e;
}
} finally {
if (isBlocking()) {
end(finished);
}
}
initLocalAddressAndPort();
connectAddress = inetSocketAddress;
if (socket != null) {
socket.socketImpl().initRemoteAddressAndPort(connectAddress.getAddress(),
connectAddress.getPort());
}
synchronized (this) {
if (isBlocking()) {
status = (finished ? SOCKET_STATUS_CONNECTED : SOCKET_STATUS_UNCONNECTED);
} else {
status = SOCKET_STATUS_PENDING;
}
}
return finished;
}
示例6: implConfigureBlocking
import libcore.io.IoUtils; //导入方法依赖的package包/类
@Override
protected void implConfigureBlocking(boolean blockMode) throws IOException {
synchronized (blockingLock()) {
IoUtils.setBlocking(fd, blockMode);
}
}