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


Java AbstractSelectionKey类代码示例

本文整理汇总了Java中java.nio.channels.spi.AbstractSelectionKey的典型用法代码示例。如果您正苦于以下问题:Java AbstractSelectionKey类的具体用法?Java AbstractSelectionKey怎么用?Java AbstractSelectionKey使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


AbstractSelectionKey类属于java.nio.channels.spi包,在下文中一共展示了AbstractSelectionKey类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doCancel

import java.nio.channels.spi.AbstractSelectionKey; //导入依赖的package包/类
/**
 * Removes cancelled keys from the key set and selected key set, and
 * unregisters the corresponding channels. Returns the number of keys
 * removed from the selected key set.
 */
private int doCancel() {
    int deselected = 0;

    Set<SelectionKey> cancelledKeys = cancelledKeys();
    synchronized (cancelledKeys) {
        if (cancelledKeys.size() > 0) {
            for (SelectionKey currentKey : cancelledKeys) {
                mutableKeys.remove(currentKey);
                deregister((AbstractSelectionKey) currentKey);
                if (mutableSelectedKeys.remove(currentKey)) {
                    deselected++;
                }
            }
            cancelledKeys.clear();
        }
    }

    return deselected;
}
 
开发者ID:Sellegit,项目名称:j2objc,代码行数:25,代码来源:SelectorImpl.java

示例2: doCancel

import java.nio.channels.spi.AbstractSelectionKey; //导入依赖的package包/类
/**
 * Removes cancelled keys from the key set and selected key set, and
 * deregisters the corresponding channels. Returns the number of keys
 * removed from the selected key set.
 */
private int doCancel() {
    int deselected = 0;

    Set<SelectionKey> cancelledKeys = cancelledKeys();
    synchronized (cancelledKeys) {
        if (cancelledKeys.size() > 0) {
            for (SelectionKey currentKey : cancelledKeys) {
                mutableKeys.remove(currentKey);
                deregister((AbstractSelectionKey) currentKey);
                if (mutableSelectedKeys.remove(currentKey)) {
                    deselected++;
                }
            }
            cancelledKeys.clear();
        }
    }

    return deselected;
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:25,代码来源:SelectorImpl.java

示例3: test_deregister

import java.nio.channels.spi.AbstractSelectionKey; //导入依赖的package包/类
@TestTargetNew(
    level = TestLevel.COMPLETE,
    notes = "",
    method = "deregister",
    args = {AbstractSelectionKey.class}
)
public void test_deregister() throws Exception {
    MockSelectorProvider prov = new MockSelectorProvider();
    AbstractSelector acceptSelector = prov.openSelector();
    SocketChannel sc = prov.openSocketChannel();
    sc.configureBlocking(false);

    SelectionKey acceptKey = sc.register(acceptSelector,
            SelectionKey.OP_READ, null);
    assertTrue(sc.isRegistered());
    assertNotNull(acceptKey);
    ((MockAbstractSelector)acceptSelector).mockDeregister(
            (MockAbstractSelector.MockSelectionKey)acceptKey);
    assertFalse(sc.isRegistered());
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:21,代码来源:AbstractSelectorTest.java

示例4: implCloseSelector

import java.nio.channels.spi.AbstractSelectionKey; //导入依赖的package包/类
/**
 * @see java.nio.channels.spi.AbstractSelector#implCloseSelector()
 */
@Override
protected void implCloseSelector() throws IOException {
    wakeup();
    synchronized (this) {
        synchronized (unmodifiableKeys) {
            synchronized (selectedKeys) {
                sink.close();
                source.close();
                doCancel();
                for (SelectionKey sk : mutableKeys) {
                    deregister((AbstractSelectionKey) sk);
                }
            }
        }
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:20,代码来源:SelectorImpl.java

示例5: implCloseSelector

import java.nio.channels.spi.AbstractSelectionKey; //导入依赖的package包/类
@Override protected void implCloseSelector() throws IOException {
    wakeup();
    synchronized (this) {
        synchronized (unmodifiableKeys) {
            synchronized (selectedKeys) {
                IoUtils.close(wakeupIn);
                IoUtils.close(wakeupOut);
                doCancel();
                for (SelectionKey sk : mutableKeys) {
                    deregister((AbstractSelectionKey) sk);
                }
            }
        }
    }
}
 
开发者ID:Sellegit,项目名称:j2objc,代码行数:16,代码来源:SelectorImpl.java

示例6: implCloseSelector

import java.nio.channels.spi.AbstractSelectionKey; //导入依赖的package包/类
@Override protected void implCloseSelector() throws IOException {
    wakeup();
    synchronized (this) {
        synchronized (unmodifiableKeys) {
            synchronized (selectedKeys) {
                wakeupPipe.sink().close();
                wakeupPipe.source().close();
                doCancel();
                for (SelectionKey sk : mutableKeys) {
                    deregister((AbstractSelectionKey) sk);
                }
            }
        }
    }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:16,代码来源:SelectorImpl.java

示例7: implCloseSelector

import java.nio.channels.spi.AbstractSelectionKey; //导入依赖的package包/类
protected void implCloseSelector() throws IOException {
    synchronized (this) {
        synchronized (keysSet) {
            synchronized (selectedKeys) {
                doCancel();
                for (int c = 0; c < keysCount; c++) {
                    if (keys[c] != null) {
                        deregister((AbstractSelectionKey) keys[c]);
                    }
                }
                wakeup();
            }
        }
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:16,代码来源:EpollSelectorImpl.java

示例8: doCancel

import java.nio.channels.spi.AbstractSelectionKey; //导入依赖的package包/类
private void doCancel() {
    Set<SelectionKey> cancelledKeys = cancelledKeys();
    synchronized (cancelledKeys) {
        if (cancelledKeys.size() > 0) {
            for (SelectionKey currentkey : cancelledKeys) {
                delKey(currentkey);
                deregister((AbstractSelectionKey) currentkey);
                selectedKeys.remove(currentkey);
            }
        }
        cancelledKeys.clear();
        limitCapacity();
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:15,代码来源:EpollSelectorImpl.java

示例9: doCancel

import java.nio.channels.spi.AbstractSelectionKey; //导入依赖的package包/类
private void doCancel() {
    Set<SelectionKey> cancelledKeys = cancelledKeys();
    synchronized (cancelledKeys) {
        if (cancelledKeys.size() > 0) {
            for (SelectionKey currentkey : cancelledKeys) {
                delKey((SelectionKeyImpl)currentkey);
                mutableKeys.remove(currentkey);
                deregister((AbstractSelectionKey) currentkey);
                mutableSelectedKeys.remove(currentkey);
            }
            cancelledKeys.clear();
        }
        limitCapacity();
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:16,代码来源:SelectorImpl.java

示例10: implCloseSelector

import java.nio.channels.spi.AbstractSelectionKey; //导入依赖的package包/类
protected void implCloseSelector() throws IOException {
    doCancel();
    for (SelectionKey sk : keys) {
        deregister((AbstractSelectionKey) sk);
    }
    wakeup();
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:8,代码来源:SelectorImpl.java

示例11: doCancel

import java.nio.channels.spi.AbstractSelectionKey; //导入依赖的package包/类
private void doCancel() {
    Set<SelectionKey> cancelledKeys = cancelledKeys();
    synchronized (cancelledKeys) {
        if (cancelledKeys.size() > 0) {
            for (SelectionKey currentkey : cancelledKeys) {
                deregister((AbstractSelectionKey) currentkey);
                keys.remove(currentkey);
                selectedKeys.remove(currentkey);
            }
        }
        cancelledKeys.clear();
    }
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:14,代码来源:SelectorImpl.java

示例12: mockDeregister

import java.nio.channels.spi.AbstractSelectionKey; //导入依赖的package包/类
public void mockDeregister(AbstractSelectionKey key) {
    super.deregister(key);
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:4,代码来源:MockAbstractSelector.java

示例13: selectInternal

import java.nio.channels.spi.AbstractSelectionKey; //导入依赖的package包/类
private int selectInternal(long timeout) throws IOException {
    closeCheck();
    synchronized (this) {
        synchronized (unmodifiableKeys) {
            synchronized (selectedKeys) {
                doCancel();
                boolean isBlock = (SELECT_NOW != timeout);
                prepareChannels();
                boolean success;
                try {
                    if (isBlock) {
                        begin();
                    }
                    success = Platform.getNetworkSystem().select(
                            readableFDs, writableFDs, readableKeysCount, writableKeysCount, timeout, flags);
                } finally {
                    if (isBlock) {
                        end();
                    }
                }

                int selected = success ? processSelectResult() : 0;

                Arrays.fill(flags, 0);

                Set<SelectionKey> cancelledKeys = cancelledKeys();
                synchronized (cancelledKeys) {
                    if (cancelledKeys.size() > 0) {
                        for (SelectionKey currentkey : cancelledKeys) {
                            delKey((SelectionKeyImpl)currentkey);
                            mutableKeys.remove(currentkey);
                            deregister((AbstractSelectionKey) currentkey);
                            if (mutableSelectedKeys.remove(currentkey)) {
                                selected--;
                            }
                        }
                        cancelledKeys.clear();
                    }
                    limitCapacity();
                }

                return selected;
            }
        }
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:47,代码来源:SelectorImpl.java

示例14: mockDeregister

import java.nio.channels.spi.AbstractSelectionKey; //导入依赖的package包/类
protected void mockDeregister(AbstractSelectionKey key) {
	super.deregister(key);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:4,代码来源:MockAbstractSelector.java


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