当前位置: 首页>>代码示例>>Java>>正文


Java IoUtils.setBlocking方法代码示例

本文整理汇总了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();
    }
}
 
开发者ID:Sellegit,项目名称:j2objc,代码行数:20,代码来源:SelectorImpl.java

示例2: implConfigureBlocking

import libcore.io.IoUtils; //导入方法依赖的package包/类
@Override protected void implConfigureBlocking(boolean blocking) throws IOException {
    IoUtils.setBlocking(fd, blocking);
}
 
开发者ID:Sellegit,项目名称:j2objc,代码行数:4,代码来源:DatagramChannelImpl.java

示例3: implConfigureBlocking

import libcore.io.IoUtils; //导入方法依赖的package包/类
@Override protected void implConfigureBlocking(boolean blocking) throws IOException {
    IoUtils.setBlocking(socket.getFD$(), blocking);
}
 
开发者ID:Sellegit,项目名称:j2objc,代码行数:4,代码来源:ServerSocketChannelImpl.java

示例4: implConfigureBlocking

import libcore.io.IoUtils; //导入方法依赖的package包/类
@Override protected void implConfigureBlocking(boolean blocking) throws IOException {
    IoUtils.setBlocking(getFD(), blocking);
}
 
开发者ID:Sellegit,项目名称:j2objc,代码行数:4,代码来源:PipeImpl.java

示例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;
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:72,代码来源:SocketChannelImpl.java

示例6: implConfigureBlocking

import libcore.io.IoUtils; //导入方法依赖的package包/类
@Override
protected void implConfigureBlocking(boolean blockMode) throws IOException {
    synchronized (blockingLock()) {
        IoUtils.setBlocking(fd, blockMode);
    }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:7,代码来源:SocketChannelImpl.java


注:本文中的libcore.io.IoUtils.setBlocking方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。