private void execute(Runnable task) { try { _selectorManager.execute(task); } catch (RejectedExecutionException x) { if (task instanceof Closeable) closeNoExceptions((Closeable)task); } }
private void execute(Runnable task) { try { _selectorManager.execute(task); } catch (RejectedExecutionException x) { if (task instanceof Closeable) closeNoExceptions((Closeable)task); } }
@Override protected void doStart() throws Exception { super.doStart(); _selector = newSelector(); _selectorManager.execute(this); }
@Override public void run() { try { for (SelectionKey key : _selector.keys()) { Object attachment = key.attachment(); if (attachment instanceof EndPoint) { EndPointCloser closer = new EndPointCloser((EndPoint)attachment); execute(closer); // We are closing the SelectorManager, so we want to block the // selector thread here until we have closed all EndPoints. // This is different than calling close() directly, because close() // can wait forever, while here we are limited by the stop timeout. closer.await(getStopTimeout()); } } closeNoExceptions(_selector); } finally { latch.countDown(); } }
@Override public void run() { try { for (SelectionKey key : _selector.keys()) { Object attachment = key.attachment(); if (attachment instanceof EndPoint) { EndPointCloser closer = new EndPointCloser((EndPoint)attachment); execute(closer); // We are closing the SelectorManager, so we want to block the // selector thread here until we have closed all EndPoints. // This is different than calling close() directly, because close() // can wait forever, while here we are limited by the stop timeout. closer.await(getStopTimeout()); } } closeNoExceptions(_selector); } finally { latch.countDown(); } }
@Override public void run() { try { for (SelectionKey key : _selector.keys()) { Object attachment = key.attachment(); if (attachment instanceof EndPoint) { EndPointCloser closer = new EndPointCloser((EndPoint)attachment); execute(closer); // We are closing the SelectorManager, so we want to block the // selector thread here until we have closed all EndPoints. // This is different than calling close() directly, because close() // can wait forever, while here we are limited by the stop timeout. closer.await(getStopTimeout()); } } closeNoExceptions(_selector); } finally { latch.countDown(); } }
@Override protected void doStart() throws Exception { super.doStart(); for (int i = 0; i < _selectors.length; i++) { ManagedSelector selector = newSelector(i); _selectors[i] = selector; selector.start(); execute(selector); } }
@Override protected void doStart() throws Exception { super.doStart(); for (int i = 0; i < _selectors.length; i++) { ManagedSelector selector = newSelector(i); _selectors[i] = selector; selector.start(); execute(selector); } }
@Override protected void doStart() throws Exception { super.doStart(); _selector = _selectorManager.newSelector(); // The producer used by the strategies will never // be idle (either produces a task or blocks). // The normal strategy obtains the produced task, schedules // a new thread to produce more, runs the task and then exits. _selectorManager.execute(_strategy::produce); // Set started only if we really are started Start start = new Start(); submit(start); start._started.await(); }
@Override protected void doStart() throws Exception { super.doStart(); _selector = _selectorManager.newSelector(); // The producer used by the strategies will never // be idle (either produces a task or blocks). // The normal strategy obtains the produced task, schedules // a new thread to produce more, runs the task and then exits. _selectorManager.execute(_strategy::produce); // Set started only if we really are started Start start = new Start(); submit(start); start._started.await(); }
@Override protected void doStart() throws Exception { super.doStart(); for (int i = 0; i < _selectors.length; i++) { ManagedSelector selector = newSelector(i); _selectors[i] = selector; selector.start(); execute(new NonBlockingThread(selector)); } }