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 File: SelectorImpl.java    From jdk8u60 with 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 File: SelectorImpl.java    From jdk1.8-source-analysis with 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 #3
Source File: SelectorImpl.java    From openjdk-jdk8u with 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 #4
Source File: SelectorImpl.java    From openjdk-8 with 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 #5
Source File: SelectorImpl.java    From hottub with 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 File: SelectorImpl.java    From jdk1.8-source-analysis with 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 #7
Source File: SelectorImpl.java    From openjdk-jdk8u-backup with 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 #8
Source File: SelectorImpl.java    From JDKSourceCode1.8 with 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 File: SelectorImpl.java    From openjdk-jdk8u with 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 #10
Source File: SelectorImpl.java    From openjdk-8 with 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 File: SelectorImpl.java    From TencentKona-8 with 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 File: SelectorImpl.java    From TencentKona-8 with 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 File: SelectorImpl.java    From JDKSourceCode1.8 with 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 #14
Source File: SelectorImpl.java    From openjdk-jdk9 with 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 #15
Source File: SelectorImpl.java    From openjdk-8-source with 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 #16
Source File: SelectorImpl.java    From JDKSourceCode1.8 with 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();
    }
}
 
Example #17
Source File: SelectorImpl.java    From openjdk-8 with 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 #18
Source File: SelectorImpl.java    From JDKSourceCode1.8 with 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 #19
Source File: SelectorImpl.java    From JDKSourceCode1.8 with 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 #20
Source File: SelectorImpl.java    From openjdk-jdk8u with 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
        try {
            if (selector != null) {
                // wakeup Selector thread to process close request
                selector.wakeup();
            }
        } catch (Throwable t) {
            if (orb.transportDebugFlag) {
                dprint(".registerInterestOps: selector.wakeup: ", t);
            }
        }
    }
    else {
        wrapper.selectionKeyInvalid(eventHandler.toString());
        if (orb.transportDebugFlag) {
            dprint(".registerInterestOps: EventHandler SelectionKey not valid " + eventHandler);
        }
    }

    if (orb.transportDebugFlag) {
        dprint(".registerInterestOps:<- ");
    }
}
 
Example #21
Source File: SelectorImpl.java    From openjdk-8 with 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 #22
Source File: SelectorImpl.java    From hottub with 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 #23
Source File: SelectorImpl.java    From openjdk-jdk9 with 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
        try {
            if (selector != null) {
                // wakeup Selector thread to process close request
                selector.wakeup();
            }
        } catch (Throwable t) {
            if (orb.transportDebugFlag) {
                dprint(".registerInterestOps: selector.wakeup: ", t);
            }
        }
    }
    else {
        wrapper.selectionKeyInvalid(eventHandler.toString());
        if (orb.transportDebugFlag) {
            dprint(".registerInterestOps: EventHandler SelectionKey not valid " + eventHandler);
        }
    }

    if (orb.transportDebugFlag) {
        dprint(".registerInterestOps:<- ");
    }
}
 
Example #24
Source File: SelectorImpl.java    From jdk8u60 with 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 #25
Source File: SelectorImpl.java    From openjdk-jdk8u with 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 #26
Source File: SelectorImpl.java    From openjdk-8 with 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 #27
Source File: SelectorImpl.java    From jdk8u60 with 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 #28
Source File: SelectorImpl.java    From jdk8u60 with 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 #29
Source File: SelectorImpl.java    From jdk8u60 with 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 #30
Source File: SelectorImpl.java    From openjdk-jdk8u-backup with 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
        try {
            if (selector != null) {
                // wakeup Selector thread to process close request
                selector.wakeup();
            }
        } catch (Throwable t) {
            if (orb.transportDebugFlag) {
                dprint(".registerInterestOps: selector.wakeup: ", t);
            }
        }
    }
    else {
        wrapper.selectionKeyInvalid(eventHandler.toString());
        if (orb.transportDebugFlag) {
            dprint(".registerInterestOps: EventHandler SelectionKey not valid " + eventHandler);
        }
    }

    if (orb.transportDebugFlag) {
        dprint(".registerInterestOps:<- ");
    }
}