com.sun.corba.se.pept.transport.EventHandler Java Examples

The following examples show how to use com.sun.corba.se.pept.transport.EventHandler. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: openjdk-8   Author: bpupadhyaya   File: SelectorImpl.java    License: GNU General Public License v2.0 6 votes vote down vote up
private void destroyReaderThread(EventHandler eventHandler)
{
    if (orb.transportDebugFlag) {
        dprint(".destroyReaderThread: " + eventHandler);
    }
    ReaderThread readerThread = (ReaderThread)
        readerThreads.get(eventHandler);
    if (readerThread == null) {
        if (orb.transportDebugFlag) {
            dprint(".destroyReaderThread: cannot find ReaderThread - ignoring.");
        }
        return;
    }
    readerThreads.remove(eventHandler);
    readerThread.close();
}
 
Example #2
Source Project: jdk1.8-source-analysis   Author: raysonfang   File: SelectorImpl.java    License: Apache License 2.0 6 votes vote down vote up
private void destroyListenerThread(EventHandler eventHandler)
{
    if (orb.transportDebugFlag) {
        dprint(".destroyListenerThread: " + eventHandler);
    }
    ListenerThread listenerThread = (ListenerThread)
        listenerThreads.get(eventHandler);
    if (listenerThread == null) {
        if (orb.transportDebugFlag) {
            dprint(".destroyListenerThread: cannot find ListenerThread - ignoring.");
        }
        return;
    }
    listenerThreads.remove(eventHandler);
    listenerThread.close();
}
 
Example #3
Source Project: jdk1.8-source-analysis   Author: raysonfang   File: SelectorImpl.java    License: Apache License 2.0 6 votes vote down vote up
private void destroyReaderThread(EventHandler eventHandler)
{
    if (orb.transportDebugFlag) {
        dprint(".destroyReaderThread: " + eventHandler);
    }
    ReaderThread readerThread = (ReaderThread)
        readerThreads.get(eventHandler);
    if (readerThread == null) {
        if (orb.transportDebugFlag) {
            dprint(".destroyReaderThread: cannot find ReaderThread - ignoring.");
        }
        return;
    }
    readerThreads.remove(eventHandler);
    readerThread.close();
}
 
Example #4
Source Project: TencentKona-8   Author: Tencent   File: SelectorImpl.java    License: GNU General Public License v2.0 6 votes vote down vote up
private void destroyListenerThread(EventHandler eventHandler)
{
    if (orb.transportDebugFlag) {
        dprint(".destroyListenerThread: " + eventHandler);
    }
    ListenerThread listenerThread = (ListenerThread)
        listenerThreads.get(eventHandler);
    if (listenerThread == null) {
        if (orb.transportDebugFlag) {
            dprint(".destroyListenerThread: cannot find ListenerThread - ignoring.");
        }
        return;
    }
    listenerThreads.remove(eventHandler);
    listenerThread.close();
}
 
Example #5
Source Project: TencentKona-8   Author: Tencent   File: SelectorImpl.java    License: GNU General Public License v2.0 6 votes vote down vote up
private void destroyReaderThread(EventHandler eventHandler)
{
    if (orb.transportDebugFlag) {
        dprint(".destroyReaderThread: " + eventHandler);
    }
    ReaderThread readerThread = (ReaderThread)
        readerThreads.get(eventHandler);
    if (readerThread == null) {
        if (orb.transportDebugFlag) {
            dprint(".destroyReaderThread: cannot find ReaderThread - ignoring.");
        }
        return;
    }
    readerThreads.remove(eventHandler);
    readerThread.close();
}
 
Example #6
Source Project: jdk8u60   Author: chenghanpeng   File: SelectorImpl.java    License: GNU General Public License v2.0 6 votes vote down vote up
private void destroyReaderThread(EventHandler eventHandler)
{
    if (orb.transportDebugFlag) {
        dprint(".destroyReaderThread: " + eventHandler);
    }
    ReaderThread readerThread = (ReaderThread)
        readerThreads.get(eventHandler);
    if (readerThread == null) {
        if (orb.transportDebugFlag) {
            dprint(".destroyReaderThread: cannot find ReaderThread - ignoring.");
        }
        return;
    }
    readerThreads.remove(eventHandler);
    readerThread.close();
}
 
Example #7
Source Project: JDKSourceCode1.8   Author: wupeixuan   File: SelectorImpl.java    License: MIT License 6 votes vote down vote up
private void destroyListenerThread(EventHandler eventHandler)
{
    if (orb.transportDebugFlag) {
        dprint(".destroyListenerThread: " + eventHandler);
    }
    ListenerThread listenerThread = (ListenerThread)
        listenerThreads.get(eventHandler);
    if (listenerThread == null) {
        if (orb.transportDebugFlag) {
            dprint(".destroyListenerThread: cannot find ListenerThread - ignoring.");
        }
        return;
    }
    listenerThreads.remove(eventHandler);
    listenerThread.close();
}
 
Example #8
Source Project: JDKSourceCode1.8   Author: wupeixuan   File: SelectorImpl.java    License: MIT License 6 votes vote down vote up
private void destroyReaderThread(EventHandler eventHandler)
{
    if (orb.transportDebugFlag) {
        dprint(".destroyReaderThread: " + eventHandler);
    }
    ReaderThread readerThread = (ReaderThread)
        readerThreads.get(eventHandler);
    if (readerThread == null) {
        if (orb.transportDebugFlag) {
            dprint(".destroyReaderThread: cannot find ReaderThread - ignoring.");
        }
        return;
    }
    readerThreads.remove(eventHandler);
    readerThread.close();
}
 
Example #9
Source Project: hottub   Author: dsrg-uoft   File: SelectorImpl.java    License: GNU General Public License v2.0 6 votes vote down vote up
private void destroyReaderThread(EventHandler eventHandler)
{
    if (orb.transportDebugFlag) {
        dprint(".destroyReaderThread: " + eventHandler);
    }
    ReaderThread readerThread = (ReaderThread)
        readerThreads.get(eventHandler);
    if (readerThread == null) {
        if (orb.transportDebugFlag) {
            dprint(".destroyReaderThread: cannot find ReaderThread - ignoring.");
        }
        return;
    }
    readerThreads.remove(eventHandler);
    readerThread.close();
}
 
Example #10
Source Project: openjdk-jdk8u   Author: AdoptOpenJDK   File: SelectorImpl.java    License: GNU General Public License v2.0 6 votes vote down vote up
private void destroyListenerThread(EventHandler eventHandler)
{
    if (orb.transportDebugFlag) {
        dprint(".destroyListenerThread: " + eventHandler);
    }
    ListenerThread listenerThread = (ListenerThread)
        listenerThreads.get(eventHandler);
    if (listenerThread == null) {
        if (orb.transportDebugFlag) {
            dprint(".destroyListenerThread: cannot find ListenerThread - ignoring.");
        }
        return;
    }
    listenerThreads.remove(eventHandler);
    listenerThread.close();
}
 
Example #11
Source Project: openjdk-jdk8u   Author: AdoptOpenJDK   File: SelectorImpl.java    License: GNU General Public License v2.0 6 votes vote down vote up
private void destroyReaderThread(EventHandler eventHandler)
{
    if (orb.transportDebugFlag) {
        dprint(".destroyReaderThread: " + eventHandler);
    }
    ReaderThread readerThread = (ReaderThread)
        readerThreads.get(eventHandler);
    if (readerThread == null) {
        if (orb.transportDebugFlag) {
            dprint(".destroyReaderThread: cannot find ReaderThread - ignoring.");
        }
        return;
    }
    readerThreads.remove(eventHandler);
    readerThread.close();
}
 
Example #12
Source Project: openjdk-8   Author: bpupadhyaya   File: SelectorImpl.java    License: GNU General Public License v2.0 6 votes vote down vote up
private void destroyListenerThread(EventHandler eventHandler)
{
    if (orb.transportDebugFlag) {
        dprint(".destroyListenerThread: " + eventHandler);
    }
    ListenerThread listenerThread = (ListenerThread)
        listenerThreads.get(eventHandler);
    if (listenerThread == null) {
        if (orb.transportDebugFlag) {
            dprint(".destroyListenerThread: cannot find ListenerThread - ignoring.");
        }
        return;
    }
    listenerThreads.remove(eventHandler);
    listenerThread.close();
}
 
Example #13
Source Project: openjdk-jdk9   Author: AdoptOpenJDK   File: SelectorImpl.java    License: GNU General Public License v2.0 6 votes vote down vote up
private void destroyListenerThread(EventHandler eventHandler)
{
    if (orb.transportDebugFlag) {
        dprint(".destroyListenerThread: " + eventHandler);
    }
    ListenerThread listenerThread = (ListenerThread)
        listenerThreads.get(eventHandler);
    if (listenerThread == null) {
        if (orb.transportDebugFlag) {
            dprint(".destroyListenerThread: cannot find ListenerThread - ignoring.");
        }
        return;
    }
    listenerThreads.remove(eventHandler);
    listenerThread.close();
}
 
Example #14
Source Project: openjdk-jdk8u-backup   Author: AdoptOpenJDK   File: SelectorImpl.java    License: GNU General Public License v2.0 6 votes vote down vote up
private void destroyReaderThread(EventHandler eventHandler)
{
    if (orb.transportDebugFlag) {
        dprint(".destroyReaderThread: " + eventHandler);
    }
    ReaderThread readerThread = (ReaderThread)
        readerThreads.get(eventHandler);
    if (readerThread == null) {
        if (orb.transportDebugFlag) {
            dprint(".destroyReaderThread: cannot find ReaderThread - ignoring.");
        }
        return;
    }
    readerThreads.remove(eventHandler);
    readerThread.close();
}
 
Example #15
Source Project: jdk1.8-source-analysis   Author: raysonfang   File: SelectorImpl.java    License: Apache License 2.0 5 votes vote down vote up
public void registerForEvent(EventHandler eventHandler)
{
    if (orb.transportDebugFlag) {
        dprint(".registerForEvent: " + eventHandler);
    }

    if (isClosed()) {
        if (orb.transportDebugFlag) {
            dprint(".registerForEvent: closed: " + eventHandler);
        }
        return;
    }

    if (eventHandler.shouldUseSelectThreadToWait()) {
        synchronized (deferredRegistrations) {
            deferredRegistrations.add(eventHandler);
        }
        if (! selectorStarted) {
            startSelector();
        }
        selector.wakeup();
        return;
    }

    switch (eventHandler.getInterestOps()) {
    case SelectionKey.OP_ACCEPT :
        createListenerThread(eventHandler);
        break;
    case SelectionKey.OP_READ :
        createReaderThread(eventHandler);
        break;
    default:
        if (orb.transportDebugFlag) {
            dprint(".registerForEvent: default: " + eventHandler);
        }
        throw new RuntimeException(
            "SelectorImpl.registerForEvent: unknown interest ops");
    }
}
 
Example #16
Source Project: jdk1.8-source-analysis   Author: raysonfang   File: SelectorImpl.java    License: Apache License 2.0 5 votes vote down vote up
private void clearDeferredRegistrations() {
    synchronized (deferredRegistrations) {
        int deferredListSize = deferredRegistrations.size();
        if (orb.transportDebugFlag) {
            dprint(".clearDeferredRegistrations:deferred list size == " + deferredListSize);
        }
        for (int i = 0; i < deferredListSize; i++) {
            EventHandler eventHandler =
                (EventHandler)deferredRegistrations.get(i);
            if (orb.transportDebugFlag) {
                dprint(".clearDeferredRegistrations: " + eventHandler);
            }
            SelectableChannel channel = eventHandler.getChannel();
            SelectionKey selectionKey = null;

            try {
                if (orb.transportDebugFlag) {
                    dprint(".clearDeferredRegistrations:close channel == "
                            + channel);
                    dprint(".clearDeferredRegistrations:close channel class == "
                            + channel.getClass().getName());
                }
                channel.close();
                selectionKey = eventHandler.getSelectionKey();
                if (selectionKey != null) {
                    selectionKey.cancel();
                    selectionKey.attach(null);
                }
            } catch (IOException ioEx) {
                if (orb.transportDebugFlag) {
                    dprint(".clearDeferredRegistrations: ", ioEx);
                }
            }
        }
        deferredRegistrations.clear();
    }
}
 
Example #17
Source Project: hottub   Author: dsrg-uoft   File: SelectorImpl.java    License: GNU General Public License v2.0 5 votes vote down vote up
private void clearDeferredRegistrations() {
    synchronized (deferredRegistrations) {
        int deferredListSize = deferredRegistrations.size();
        if (orb.transportDebugFlag) {
            dprint(".clearDeferredRegistrations:deferred list size == " + deferredListSize);
        }
        for (int i = 0; i < deferredListSize; i++) {
            EventHandler eventHandler =
                (EventHandler)deferredRegistrations.get(i);
            if (orb.transportDebugFlag) {
                dprint(".clearDeferredRegistrations: " + eventHandler);
            }
            SelectableChannel channel = eventHandler.getChannel();
            SelectionKey selectionKey = null;

            try {
                if (orb.transportDebugFlag) {
                    dprint(".clearDeferredRegistrations:close channel == "
                            + channel);
                    dprint(".clearDeferredRegistrations:close channel class == "
                            + channel.getClass().getName());
                }
                channel.close();
                selectionKey = eventHandler.getSelectionKey();
                if (selectionKey != null) {
                    selectionKey.cancel();
                    selectionKey.attach(null);
                }
            } catch (IOException ioEx) {
                if (orb.transportDebugFlag) {
                    dprint(".clearDeferredRegistrations: ", ioEx);
                }
            }
        }
        deferredRegistrations.clear();
    }
}
 
Example #18
Source Project: TencentKona-8   Author: Tencent   File: SelectorImpl.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void registerForEvent(EventHandler eventHandler)
{
    if (orb.transportDebugFlag) {
        dprint(".registerForEvent: " + eventHandler);
    }

    if (isClosed()) {
        if (orb.transportDebugFlag) {
            dprint(".registerForEvent: closed: " + eventHandler);
        }
        return;
    }

    if (eventHandler.shouldUseSelectThreadToWait()) {
        synchronized (deferredRegistrations) {
            deferredRegistrations.add(eventHandler);
        }
        if (! selectorStarted) {
            startSelector();
        }
        selector.wakeup();
        return;
    }

    switch (eventHandler.getInterestOps()) {
    case SelectionKey.OP_ACCEPT :
        createListenerThread(eventHandler);
        break;
    case SelectionKey.OP_READ :
        createReaderThread(eventHandler);
        break;
    default:
        if (orb.transportDebugFlag) {
            dprint(".registerForEvent: default: " + eventHandler);
        }
        throw new RuntimeException(
            "SelectorImpl.registerForEvent: unknown interest ops");
    }
}
 
Example #19
Source Project: TencentKona-8   Author: Tencent   File: SelectorImpl.java    License: GNU General Public License v2.0 5 votes vote down vote up
private void clearDeferredRegistrations() {
    synchronized (deferredRegistrations) {
        int deferredListSize = deferredRegistrations.size();
        if (orb.transportDebugFlag) {
            dprint(".clearDeferredRegistrations:deferred list size == " + deferredListSize);
        }
        for (int i = 0; i < deferredListSize; i++) {
            EventHandler eventHandler =
                (EventHandler)deferredRegistrations.get(i);
            if (orb.transportDebugFlag) {
                dprint(".clearDeferredRegistrations: " + eventHandler);
            }
            SelectableChannel channel = eventHandler.getChannel();
            SelectionKey selectionKey = null;

            try {
                if (orb.transportDebugFlag) {
                    dprint(".clearDeferredRegistrations:close channel == "
                            + channel);
                    dprint(".clearDeferredRegistrations:close channel class == "
                            + channel.getClass().getName());
                }
                channel.close();
                selectionKey = eventHandler.getSelectionKey();
                if (selectionKey != null) {
                    selectionKey.cancel();
                    selectionKey.attach(null);
                }
            } catch (IOException ioEx) {
                if (orb.transportDebugFlag) {
                    dprint(".clearDeferredRegistrations: ", ioEx);
                }
            }
        }
        deferredRegistrations.clear();
    }
}
 
Example #20
Source Project: TencentKona-8   Author: Tencent   File: SelectorImpl.java    License: GNU General Public License v2.0 5 votes vote down vote up
private void handleDeferredRegistrations()
{
    synchronized (deferredRegistrations) {
        int deferredListSize = deferredRegistrations.size();
        for (int i = 0; i < deferredListSize; i++) {
            EventHandler eventHandler =
                (EventHandler)deferredRegistrations.get(i);
            if (orb.transportDebugFlag) {
                dprint(".handleDeferredRegistrations: " + eventHandler);
            }
            SelectableChannel channel = eventHandler.getChannel();
            SelectionKey selectionKey = null;
            try {
                selectionKey =
                    channel.register(selector,
                                     eventHandler.getInterestOps(),
                                     (Object)eventHandler);
            } catch (ClosedChannelException e) {
                if (orb.transportDebugFlag) {
                    dprint(".handleDeferredRegistrations: ", e);
                }
            }
            eventHandler.setSelectionKey(selectionKey);
        }
        deferredRegistrations.clear();
    }
}
 
Example #21
Source Project: openjdk-8-source   Author: keerath   File: SelectorImpl.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void registerInterestOps(EventHandler eventHandler)
{
    if (orb.transportDebugFlag) {
        dprint(".registerInterestOps:-> " + eventHandler);
    }

    SelectionKey selectionKey = eventHandler.getSelectionKey();
    if (selectionKey.isValid()) {
        int ehOps = eventHandler.getInterestOps();
        SelectionKeyAndOp keyAndOp = new SelectionKeyAndOp(selectionKey, ehOps);
        synchronized(interestOpsList) {
            interestOpsList.add(keyAndOp);
        }
        // tell Selector Thread there's an update to a SelectorKey's Ops
        selector.wakeup();
    }
    else {
        wrapper.selectionKeyInvalid(eventHandler.toString());
        if (orb.transportDebugFlag) {
            dprint(".registerInterestOps: EventHandler SelectionKey not valid " + eventHandler);
        }
    }

    if (orb.transportDebugFlag) {
        dprint(".registerInterestOps:<- ");
    }
}
 
Example #22
Source Project: jdk8u60   Author: chenghanpeng   File: SelectorImpl.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void registerInterestOps(EventHandler eventHandler)
{
    if (orb.transportDebugFlag) {
        dprint(".registerInterestOps:-> " + eventHandler);
    }

    SelectionKey selectionKey = eventHandler.getSelectionKey();
    if (selectionKey.isValid()) {
        int ehOps = eventHandler.getInterestOps();
        SelectionKeyAndOp keyAndOp = new SelectionKeyAndOp(selectionKey, ehOps);
        synchronized(interestOpsList) {
            interestOpsList.add(keyAndOp);
        }
        // tell Selector Thread there's an update to a SelectorKey's Ops
        selector.wakeup();
    }
    else {
        wrapper.selectionKeyInvalid(eventHandler.toString());
        if (orb.transportDebugFlag) {
            dprint(".registerInterestOps: EventHandler SelectionKey not valid " + eventHandler);
        }
    }

    if (orb.transportDebugFlag) {
        dprint(".registerInterestOps:<- ");
    }
}
 
Example #23
Source Project: jdk8u60   Author: chenghanpeng   File: SelectorImpl.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void registerForEvent(EventHandler eventHandler)
{
    if (orb.transportDebugFlag) {
        dprint(".registerForEvent: " + eventHandler);
    }

    if (isClosed()) {
        if (orb.transportDebugFlag) {
            dprint(".registerForEvent: closed: " + eventHandler);
        }
        return;
    }

    if (eventHandler.shouldUseSelectThreadToWait()) {
        synchronized (deferredRegistrations) {
            deferredRegistrations.add(eventHandler);
        }
        if (! selectorStarted) {
            startSelector();
        }
        selector.wakeup();
        return;
    }

    switch (eventHandler.getInterestOps()) {
    case SelectionKey.OP_ACCEPT :
        createListenerThread(eventHandler);
        break;
    case SelectionKey.OP_READ :
        createReaderThread(eventHandler);
        break;
    default:
        if (orb.transportDebugFlag) {
            dprint(".registerForEvent: default: " + eventHandler);
        }
        throw new RuntimeException(
            "SelectorImpl.registerForEvent: unknown interest ops");
    }
}
 
Example #24
Source Project: jdk8u60   Author: chenghanpeng   File: SelectorImpl.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void unregisterForEvent(EventHandler eventHandler)
{
    if (orb.transportDebugFlag) {
        dprint(".unregisterForEvent: " + eventHandler);
    }

    if (isClosed()) {
        if (orb.transportDebugFlag) {
            dprint(".unregisterForEvent: closed: " + eventHandler);
        }
        return;
    }

    if (eventHandler.shouldUseSelectThreadToWait()) {
        SelectionKey selectionKey ;
        synchronized(deferredRegistrations) {
            selectionKey = eventHandler.getSelectionKey();
        }
        if (selectionKey != null) {
            selectionKey.cancel();
        }
        selector.wakeup();
        return;
    }

    switch (eventHandler.getInterestOps()) {
    case SelectionKey.OP_ACCEPT :
        destroyListenerThread(eventHandler);
        break;
    case SelectionKey.OP_READ :
        destroyReaderThread(eventHandler);
        break;
    default:
        if (orb.transportDebugFlag) {
            dprint(".unregisterForEvent: default: " + eventHandler);
        }
        throw new RuntimeException(
            "SelectorImpl.uregisterForEvent: unknown interest ops");
    }
}
 
Example #25
Source Project: jdk8u60   Author: chenghanpeng   File: SelectorImpl.java    License: GNU General Public License v2.0 5 votes vote down vote up
private void handleDeferredRegistrations()
{
    synchronized (deferredRegistrations) {
        int deferredListSize = deferredRegistrations.size();
        for (int i = 0; i < deferredListSize; i++) {
            EventHandler eventHandler =
                (EventHandler)deferredRegistrations.get(i);
            if (orb.transportDebugFlag) {
                dprint(".handleDeferredRegistrations: " + eventHandler);
            }
            SelectableChannel channel = eventHandler.getChannel();
            SelectionKey selectionKey = null;
            try {
                selectionKey =
                    channel.register(selector,
                                     eventHandler.getInterestOps(),
                                     (Object)eventHandler);
            } catch (ClosedChannelException e) {
                if (orb.transportDebugFlag) {
                    dprint(".handleDeferredRegistrations: " + e);
                }
            }
            eventHandler.setSelectionKey(selectionKey);
        }
        deferredRegistrations.clear();
    }
}
 
Example #26
Source Project: openjdk-8   Author: bpupadhyaya   File: SelectorImpl.java    License: GNU General Public License v2.0 5 votes vote down vote up
private void handleDeferredRegistrations()
{
    synchronized (deferredRegistrations) {
        int deferredListSize = deferredRegistrations.size();
        for (int i = 0; i < deferredListSize; i++) {
            EventHandler eventHandler =
                (EventHandler)deferredRegistrations.get(i);
            if (orb.transportDebugFlag) {
                dprint(".handleDeferredRegistrations: " + eventHandler);
            }
            SelectableChannel channel = eventHandler.getChannel();
            SelectionKey selectionKey = null;
            try {
                selectionKey =
                    channel.register(selector,
                                     eventHandler.getInterestOps(),
                                     (Object)eventHandler);
            } catch (ClosedChannelException e) {
                if (orb.transportDebugFlag) {
                    dprint(".handleDeferredRegistrations: " + e);
                }
            }
            eventHandler.setSelectionKey(selectionKey);
        }
        deferredRegistrations.clear();
    }
}
 
Example #27
Source Project: JDKSourceCode1.8   Author: wupeixuan   File: SelectorImpl.java    License: MIT License 5 votes vote down vote up
public void registerForEvent(EventHandler eventHandler)
{
    if (orb.transportDebugFlag) {
        dprint(".registerForEvent: " + eventHandler);
    }

    if (isClosed()) {
        if (orb.transportDebugFlag) {
            dprint(".registerForEvent: closed: " + eventHandler);
        }
        return;
    }

    if (eventHandler.shouldUseSelectThreadToWait()) {
        synchronized (deferredRegistrations) {
            deferredRegistrations.add(eventHandler);
        }
        if (! selectorStarted) {
            startSelector();
        }
        selector.wakeup();
        return;
    }

    switch (eventHandler.getInterestOps()) {
    case SelectionKey.OP_ACCEPT :
        createListenerThread(eventHandler);
        break;
    case SelectionKey.OP_READ :
        createReaderThread(eventHandler);
        break;
    default:
        if (orb.transportDebugFlag) {
            dprint(".registerForEvent: default: " + eventHandler);
        }
        throw new RuntimeException(
            "SelectorImpl.registerForEvent: unknown interest ops");
    }
}
 
Example #28
Source Project: openjdk-8   Author: bpupadhyaya   File: SelectorImpl.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void registerInterestOps(EventHandler eventHandler)
{
    if (orb.transportDebugFlag) {
        dprint(".registerInterestOps:-> " + eventHandler);
    }

    SelectionKey selectionKey = eventHandler.getSelectionKey();
    if (selectionKey.isValid()) {
        int ehOps = eventHandler.getInterestOps();
        SelectionKeyAndOp keyAndOp = new SelectionKeyAndOp(selectionKey, ehOps);
        synchronized(interestOpsList) {
            interestOpsList.add(keyAndOp);
        }
        // tell Selector Thread there's an update to a SelectorKey's Ops
        selector.wakeup();
    }
    else {
        wrapper.selectionKeyInvalid(eventHandler.toString());
        if (orb.transportDebugFlag) {
            dprint(".registerInterestOps: EventHandler SelectionKey not valid " + eventHandler);
        }
    }

    if (orb.transportDebugFlag) {
        dprint(".registerInterestOps:<- ");
    }
}
 
Example #29
Source Project: JDKSourceCode1.8   Author: wupeixuan   File: SelectorImpl.java    License: MIT License 5 votes vote down vote up
private void clearDeferredRegistrations() {
    synchronized (deferredRegistrations) {
        int deferredListSize = deferredRegistrations.size();
        if (orb.transportDebugFlag) {
            dprint(".clearDeferredRegistrations:deferred list size == " + deferredListSize);
        }
        for (int i = 0; i < deferredListSize; i++) {
            EventHandler eventHandler =
                (EventHandler)deferredRegistrations.get(i);
            if (orb.transportDebugFlag) {
                dprint(".clearDeferredRegistrations: " + eventHandler);
            }
            SelectableChannel channel = eventHandler.getChannel();
            SelectionKey selectionKey = null;

            try {
                if (orb.transportDebugFlag) {
                    dprint(".clearDeferredRegistrations:close channel == "
                            + channel);
                    dprint(".clearDeferredRegistrations:close channel class == "
                            + channel.getClass().getName());
                }
                channel.close();
                selectionKey = eventHandler.getSelectionKey();
                if (selectionKey != null) {
                    selectionKey.cancel();
                    selectionKey.attach(null);
                }
            } catch (IOException ioEx) {
                if (orb.transportDebugFlag) {
                    dprint(".clearDeferredRegistrations: ", ioEx);
                }
            }
        }
        deferredRegistrations.clear();
    }
}
 
Example #30
Source Project: JDKSourceCode1.8   Author: wupeixuan   File: SelectorImpl.java    License: MIT License 5 votes vote down vote up
private void handleDeferredRegistrations()
{
    synchronized (deferredRegistrations) {
        int deferredListSize = deferredRegistrations.size();
        for (int i = 0; i < deferredListSize; i++) {
            EventHandler eventHandler =
                (EventHandler)deferredRegistrations.get(i);
            if (orb.transportDebugFlag) {
                dprint(".handleDeferredRegistrations: " + eventHandler);
            }
            SelectableChannel channel = eventHandler.getChannel();
            SelectionKey selectionKey = null;
            try {
                selectionKey =
                    channel.register(selector,
                                     eventHandler.getInterestOps(),
                                     (Object)eventHandler);
            } catch (ClosedChannelException e) {
                if (orb.transportDebugFlag) {
                    dprint(".handleDeferredRegistrations: ", e);
                }
            }
            eventHandler.setSelectionKey(selectionKey);
        }
        deferredRegistrations.clear();
    }
}