You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by aa...@apache.org on 2008/04/11 14:14:53 UTC
svn commit: r647134 - in /cayenne/main/trunk:
docs/doc/src/main/resources/RELEASE-NOTES.txt
framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/event/EventManager.java
Author: aadamchik
Date: Fri Apr 11 05:14:47 2008
New Revision: 647134
URL: http://svn.apache.org/viewvc?rev=647134&view=rev
Log:
CAY-1027 Orderly EventManager shutdown
Modified:
cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/event/EventManager.java
Modified: cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt?rev=647134&r1=647133&r2=647134&view=diff
==============================================================================
--- cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt (original)
+++ cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt Fri Apr 11 05:14:47 2008
@@ -25,6 +25,7 @@
CAY-999 Scaling paginated list
CAY-1010 Entity Tab switching on new entity creation
CAY-1011 Add confirmation dialog for delete actions
+CAY-1027 Orderly EventManager shutdown
Bug fixes since M3:
Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/event/EventManager.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/event/EventManager.java?rev=647134&r1=647133&r2=647134&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/event/EventManager.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/event/EventManager.java Fri Apr 11 05:14:47 2008
@@ -49,7 +49,8 @@
protected Map<EventSubject, DispatchQueue> subjects;
protected List<Dispatch> eventQueue;
protected boolean singleThread;
- protected boolean stopped;
+ protected volatile boolean stopped;
+ List<DispatchThread> dispatchThreads;
/**
* Returns the shared EventManager. It is created on demand on the first call to this
@@ -82,13 +83,25 @@
* less.
*/
public EventManager(int dispatchThreadCount) {
- this.subjects = Collections.synchronizedMap(new WeakHashMap<EventSubject, DispatchQueue>());
+ this.subjects = Collections
+ .synchronizedMap(new WeakHashMap<EventSubject, DispatchQueue>());
this.eventQueue = Collections.synchronizedList(new LinkedList<Dispatch>());
this.singleThread = dispatchThreadCount <= 0;
- // start dispatch threads
- for (int i = 0; i < dispatchThreadCount; i++) {
- new DispatchThread("EventDispatchThread-" + i).start();
+ if (!singleThread) {
+ dispatchThreads = new ArrayList<DispatchThread>(dispatchThreadCount);
+
+ String prefix = "cayenne-edt-" + hashCode() + "-";
+
+ // start dispatch threads
+ for (int i = 0; i < dispatchThreadCount; i++) {
+ DispatchThread thread = new DispatchThread(prefix + i);
+ dispatchThreads.add(thread);
+ thread.start();
+ }
+ }
+ else {
+ dispatchThreads = Collections.emptyList();
}
}
@@ -118,14 +131,16 @@
/**
* Stops event threads. After the EventManager is stopped, it can not be restarted and
- * should be discarded. Note that dispatch threads may still run for a few more minutes
- * after this method call until they time out.
+ * should be discarded.
*
* @since 3.0
*/
public void shutdown() {
this.stopped = true;
- // threads will time out eventually...
+
+ for(DispatchThread thread : dispatchThreads) {
+ thread.interrupt();
+ }
}
/**
@@ -431,8 +446,8 @@
// dispatched in a separate thread
final class NonBlockingInvocation extends Invocation {
- public NonBlockingInvocation(Object target, String methodName, Class<?> parameterType)
- throws NoSuchMethodException {
+ public NonBlockingInvocation(Object target, String methodName,
+ Class<?> parameterType) throws NoSuchMethodException {
super(target, methodName, parameterType);
}
}