Search in sources :

Example 1 with Keys

use of org.webpieces.nio.api.jdk.Keys in project webpieces by deanhiller.

the class SelectorManager2 method selectorFired.

public void selectorFired() {
    // NOTE: we have to process registrations as close to waitOnSelector as possible.
    // otherwise, we could end up waiting on the selector when there are registrations to
    // process!!!!
    // currently, this processes the registration requests.
    fireToListeners();
    if (log.isTraceEnabled())
        log.trace("coming into select");
    final Keys keys = selector.select();
    if (log.isTraceEnabled())
        log.trace("coming out of select with newkeys=" + keys.getKeyCount() + " setSize=" + keys.getSelectedKeys().size() + " regCnt=" + listenerList.size() + " needCloseOrRegister=" + needCloseOrRegister + " wantShutdown=" + selector.isWantShutdown());
    Set<SelectionKey> keySet = keys.getSelectedKeys();
    needCloseOrRegister = false;
    if (keySet.size() > 0) {
        helper.processKeys(keySet);
    }
}
Also used : SelectionKey(java.nio.channels.SelectionKey) Keys(org.webpieces.nio.api.jdk.Keys)

Example 2 with Keys

use of org.webpieces.nio.api.jdk.Keys in project webpieces by deanhiller.

the class MockJdk method select.

@Override
public Keys select() {
    Set<SelectionKey> keys = new HashSet<>();
    for (MockSvrSideJdkChannel c : mockSvrChannel.getConnectedChannels()) {
        SelectionKey key = c.getKey();
        if (key != null)
            keys.add(key);
    }
    SelectionKey key = mockSvrChannel.getKey();
    if (key != null)
        keys.add(key);
    return new Keys(keys.size(), keys);
}
Also used : SelectionKey(java.nio.channels.SelectionKey) Keys(org.webpieces.nio.api.jdk.Keys) HashSet(java.util.HashSet)

Example 3 with Keys

use of org.webpieces.nio.api.jdk.Keys in project webpieces by deanhiller.

the class JdkSelectorImpl method select.

public Keys select() {
    try {
        int count = selector.select();
        Set<SelectionKey> selectedKeys = selector.selectedKeys();
        return new Keys(count, selectedKeys);
    } catch (IOException e) {
        throw new NioException(e);
    }
}
Also used : SelectionKey(java.nio.channels.SelectionKey) Keys(org.webpieces.nio.api.jdk.Keys) IOException(java.io.IOException) NioException(org.webpieces.util.exceptions.NioException)

Aggregations

SelectionKey (java.nio.channels.SelectionKey)3 Keys (org.webpieces.nio.api.jdk.Keys)3 IOException (java.io.IOException)1 HashSet (java.util.HashSet)1 NioException (org.webpieces.util.exceptions.NioException)1