summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-08-30 03:50:37 (EDT)
committerEike Stepper2007-08-30 03:50:37 (EDT)
commiteb75c9f24dd593621ff9652b94ba37e794e7f52f (patch)
treecdc2a15a03e685a7d5821a5637108967869a5ceb
parent478071e7bffb32238b70691d03d2065d7dcbb911 (diff)
downloadcdo-eb75c9f24dd593621ff9652b94ba37e794e7f52f.zip
cdo-eb75c9f24dd593621ff9652b94ba37e794e7f52f.tar.gz
cdo-eb75c9f24dd593621ff9652b94ba37e794e7f52f.tar.bz2
[201366] Random deadlocks
https://bugs.eclipse.org/bugs/show_bug.cgi?id=201366
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/concurrent/AsynchronousWorkSerializer.java6
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/concurrent/CompletionWorkSerializer.java9
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/concurrent/QueueWorkerWorkSerializer.java37
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/concurrent/SynchronousWorkSerializer.java5
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/concurrent/IWorkSerializer.java5
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/Channel.java9
6 files changed, 59 insertions, 12 deletions
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/concurrent/AsynchronousWorkSerializer.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/concurrent/AsynchronousWorkSerializer.java
index c7d9403..3b177cf 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/concurrent/AsynchronousWorkSerializer.java
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/concurrent/AsynchronousWorkSerializer.java
@@ -54,7 +54,7 @@ public class AsynchronousWorkSerializer implements IWorkSerializer, Runnable
return executorService;
}
- public void addWork(Runnable work)
+ public boolean addWork(Runnable work)
{
// Need to be a block of execution. Cannot add when doing last check
// XXX synchronized (newElementLock)
@@ -77,6 +77,8 @@ public class AsynchronousWorkSerializer implements IWorkSerializer, Runnable
executorService.execute(this);
}
}
+
+ return true;
}
/**
@@ -145,7 +147,7 @@ public class AsynchronousWorkSerializer implements IWorkSerializer, Runnable
@Override
public String toString()
{
- return "AsynchronousWorkSerializer[" + executorService + "]"; //$NON-NLS-1$ //$NON-NLS-2$
+ return AsynchronousWorkSerializer.class.getSimpleName();
}
/**
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/concurrent/CompletionWorkSerializer.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/concurrent/CompletionWorkSerializer.java
index 4e71f38..b499b34 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/concurrent/CompletionWorkSerializer.java
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/concurrent/CompletionWorkSerializer.java
@@ -53,8 +53,15 @@ public class CompletionWorkSerializer implements IWorkSerializer
{
}
- public void addWork(Runnable work)
+ public boolean addWork(Runnable work)
{
completionService.submit(work, true);
+ return true;
+ }
+
+ @Override
+ public String toString()
+ {
+ return CompletionWorkSerializer.class.getSimpleName();
}
}
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/concurrent/QueueWorkerWorkSerializer.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/concurrent/QueueWorkerWorkSerializer.java
new file mode 100644
index 0000000..91c3842
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/concurrent/QueueWorkerWorkSerializer.java
@@ -0,0 +1,37 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2007 Eike Stepper, Germany.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ **************************************************************************/
+package org.eclipse.net4j.internal.util.concurrent;
+
+import org.eclipse.net4j.internal.util.lifecycle.QueueWorker;
+import org.eclipse.net4j.util.concurrent.IWorkSerializer;
+import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
+
+/**
+ * @author Eike Stepper
+ */
+public class QueueWorkerWorkSerializer extends QueueWorker<Runnable> implements IWorkSerializer
+{
+ public QueueWorkerWorkSerializer()
+ {
+ LifecycleUtil.activate(this);
+ }
+
+ public void dispose()
+ {
+ deactivate();
+ }
+
+ @Override
+ protected void work(WorkContext context, Runnable element)
+ {
+ element.run();
+ }
+}
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/concurrent/SynchronousWorkSerializer.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/concurrent/SynchronousWorkSerializer.java
index 99ebcf5..0d13c2a 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/concurrent/SynchronousWorkSerializer.java
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/concurrent/SynchronousWorkSerializer.java
@@ -21,9 +21,10 @@ public class SynchronousWorkSerializer implements IWorkSerializer
{
}
- public void addWork(Runnable work)
+ public boolean addWork(Runnable work)
{
work.run();
+ return true;
}
public void dispose()
@@ -33,6 +34,6 @@ public class SynchronousWorkSerializer implements IWorkSerializer
@Override
public String toString()
{
- return "SynchronousWorkSerializer"; //$NON-NLS-1$
+ return SynchronousWorkSerializer.class.getSimpleName();
}
}
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/concurrent/IWorkSerializer.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/concurrent/IWorkSerializer.java
index 4cbeff2..ad0d835 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/concurrent/IWorkSerializer.java
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/concurrent/IWorkSerializer.java
@@ -10,16 +10,13 @@
**************************************************************************/
package org.eclipse.net4j.util.concurrent;
-import java.util.concurrent.ExecutorCompletionService;
/**
- * TODO Replace by {@link ExecutorCompletionService}?
- *
* @author Eike Stepper
*/
public interface IWorkSerializer
{
- public void addWork(Runnable work);
+ public boolean addWork(Runnable work);
public void dispose();
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/Channel.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/Channel.java
index 9e49cba..21c13ea 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/Channel.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/Channel.java
@@ -17,7 +17,7 @@ import org.eclipse.net4j.IBufferProvider;
import org.eclipse.net4j.IChannel;
import org.eclipse.net4j.IChannelID;
import org.eclipse.net4j.IConnector;
-import org.eclipse.net4j.internal.util.concurrent.CompletionWorkSerializer;
+import org.eclipse.net4j.internal.util.concurrent.AsynchronousWorkSerializer;
import org.eclipse.net4j.internal.util.concurrent.SynchronousWorkSerializer;
import org.eclipse.net4j.internal.util.lifecycle.Lifecycle;
import org.eclipse.net4j.internal.util.om.trace.ContextTracer;
@@ -184,6 +184,7 @@ public class Channel extends Lifecycle implements IChannel, IBufferProvider
}
else
{
+ // Shutting down
buffer.release();
}
}
@@ -220,8 +221,9 @@ public class Channel extends Lifecycle implements IChannel, IBufferProvider
}
else
{
- // receiveSerializer = new AsynchronousWorkSerializer(receiveExecutor);
- receiveSerializer = new CompletionWorkSerializer(receiveExecutor);
+ receiveSerializer = new AsynchronousWorkSerializer(receiveExecutor);
+ // receiveSerializer = new CompletionWorkSerializer();
+ // receiveSerializer = new QueueWorkerWorkSerializer();
}
}
@@ -314,6 +316,7 @@ public class Channel extends Lifecycle implements IChannel, IBufferProvider
}
else
{
+ // Shutting down
buffer.release();
}
}