From 363d04174d613d514f52eb445f3e3710dc71961a Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Thu, 19 Feb 2015 13:35:58 +1100 Subject: [PATCH] 460210 - ExecutionStragegy producer for SelectManager calls onOpen from produce method onClose also a Product task --- .../org/eclipse/jetty/io/ManagedSelector.java | 22 ++++++++----- .../jetty/util/thread/SpinLockTest.java | 32 ++++++++++--------- 2 files changed, 31 insertions(+), 23 deletions(-) diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/ManagedSelector.java b/jetty-io/src/main/java/org/eclipse/jetty/io/ManagedSelector.java index dc6576d4bf3..0af27cb1c9c 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/ManagedSelector.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/ManagedSelector.java @@ -408,15 +408,21 @@ public class ManagedSelector extends AbstractLifeCycle implements Runnable, Dump return endPoint; } - public void destroyEndPoint(EndPoint endPoint) + public void destroyEndPoint(final EndPoint endPoint) { - // TODO: perhaps this code should be wrapped and submitted as a task. - if (LOG.isDebugEnabled()) - LOG.debug("Destroyed {}", endPoint); - Connection connection = endPoint.getConnection(); - if (connection != null) - _selectorManager.connectionClosed(connection); - _selectorManager.endPointClosed(endPoint); + final Connection connection = endPoint.getConnection(); + submit(new Product() + { + @Override + public void run() + { + if (LOG.isDebugEnabled()) + LOG.debug("Destroyed {}", endPoint); + if (connection != null) + _selectorManager.connectionClosed(connection); + _selectorManager.endPointClosed(endPoint); + } + }); } @Override diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/thread/SpinLockTest.java b/jetty-util/src/test/java/org/eclipse/jetty/util/thread/SpinLockTest.java index 0533d7cb65d..e4160f38a5a 100644 --- a/jetty-util/src/test/java/org/eclipse/jetty/util/thread/SpinLockTest.java +++ b/jetty-util/src/test/java/org/eclipse/jetty/util/thread/SpinLockTest.java @@ -1,18 +1,20 @@ -/* ------------------------------------------------------------ */ -/** Spin Lock - *

This is a lock designed to protect VERY short sections of - * critical code. Threads attempting to take the lock will spin - * forever until the lock is available, thus it is important that - * the code protected by this lock is extremely simple and non - * blocking. The reason for this lock is that it prevents a thread - * from giving up a CPU core when contending for the lock.

- *
- * try(SpinLock.Lock lock = spinlock.lock())
- * {
- *   // something very quick and non blocking
- * }
- * 
- */ +// +// ======================================================================== +// Copyright (c) 1995-2015 Mort Bay Consulting Pty. Ltd. +// ------------------------------------------------------------------------ +// All rights reserved. This program and the accompanying materials +// are made available under the terms of the Eclipse Public License v1.0 +// and Apache License v2.0 which accompanies this distribution. +// +// The Eclipse Public License is available at +// http://www.eclipse.org/legal/epl-v10.html +// +// The Apache License v2.0 is available at +// http://www.opensource.org/licenses/apache2.0.php +// +// You may elect to redistribute this code under either of these licenses. +// ======================================================================== +// package org.eclipse.jetty.util.thread;