You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-commits@xmlgraphics.apache.org by dv...@apache.org on 2006/11/13 14:42:43 UTC
svn commit: r474308 -
/xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/UpdateManager.java
Author: dvholten
Date: Mon Nov 13 05:42:42 2006
New Revision: 474308
URL: http://svn.apache.org/viewvc?view=rev&rev=474308
Log:
make some members volatile
Modified:
xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/UpdateManager.java
Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/UpdateManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/UpdateManager.java?view=diff&rev=474308&r1=474307&r2=474308
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/UpdateManager.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/UpdateManager.java Mon Nov 13 05:42:42 2006
@@ -1,6 +1,6 @@
/*
- Copyright 2001-2003,2005 The Apache Software Foundation
+ Copyright 2001-2003,2005 The Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -71,7 +71,7 @@
* The bridge context.
*/
protected BridgeContext bridgeContext;
-
+
/**
* The document to manage.
*/
@@ -90,12 +90,12 @@
/**
* Whether the update manager is running.
*/
- protected boolean running;
+ protected volatile boolean running;
/**
* Whether the suspend() method was called.
*/
- protected boolean suspendCalled;
+ protected volatile boolean suspendCalled;
/**
* The listeners.
@@ -275,7 +275,7 @@
public void run() {
synchronized (UpdateManager.this) {
running = true;
-
+
updateTracker = new UpdateTracker();
RootGraphicsNode root = graphicsNode.getRoot();
if (root != null){
@@ -367,7 +367,7 @@
// UpdateManagerEvent ev = new UpdateManagerEvent
// (this, null, null);
// // FIXX: Must happen in a different thread!
- // fireEvent(suspendedDispatcher, ev);
+ // fireEvent(suspendedDispatcher, ev);
// fireEvent(resumedDispatcher, ev);
// }
if (updateRunnableQueue.getQueueState() != RunnableQueue.RUNNING) {
@@ -430,7 +430,7 @@
running = false;
// Now shut everything down and disconnect
- // everything before we send the
+ // everything before we send the
// UpdateMangerStopped event.
scriptingEnvironment.interrupt();
updateRunnableQueue.getThread().halt();
@@ -495,7 +495,7 @@
* @param clearPaintingTransform Indicates if the painting transform
* should be cleared as a result of this update.
*/
- protected void updateRendering(List areas,
+ protected void updateRendering(List areas,
boolean clearPaintingTransform) {
try {
UpdateManagerEvent ev = new UpdateManagerEvent
@@ -506,7 +506,7 @@
List l = new ArrayList(c);
ev = new UpdateManagerEvent
- (this, repaintManager.getOffScreen(),
+ (this, repaintManager.getOffScreen(),
l, clearPaintingTransform);
fireEvent(updateCompletedDispatcher, ev);
} catch (ThreadDeath td) {
@@ -531,7 +531,7 @@
* Repaints the dirty areas, if needed.
*/
protected void repaint() {
- if (!updateTracker.hasChanged()) {
+ if (!updateTracker.hasChanged()) {
// No changes, nothing to repaint.
outOfDateTime = 0;
return;
@@ -548,20 +548,20 @@
}
if (ctime-outOfDateTime < minRepaintTime) {
- // We very recently did a repaint check if other
+ // We very recently did a repaint check if other
// repaint runnables are pending.
synchronized (updateRunnableQueue.getIteratorLock()) {
Iterator i = updateRunnableQueue.iterator();
while (i.hasNext())
if (!(i.next() instanceof NoRepaintRunnable))
// have a pending repaint runnable so we
- // will skip this repaint and we will let
+ // will skip this repaint and we will let
// the next one pick it up.
return;
-
+
}
}
-
+
List dirtyAreas = updateTracker.getDirtyAreas();
updateTracker.clear();
if (dirtyAreas != null) {
@@ -571,7 +571,7 @@
}
/**
- * Users of Batik should essentially never call
+ * Users of Batik should essentially never call
* this directly from Java. If the Canvas is not
* updating when you change the SVG Document it is almost
* certainly because you are not making your changes
@@ -580,11 +580,11 @@
* changes to the document in the UpdateManager's
* RunnableQueue.
*
- * This method exists to implement the
+ * This method exists to implement the
* 'SVGSVGElement.forceRedraw()' method.
*/
public void forceRepaint() {
- if (!updateTracker.hasChanged()) {
+ if (!updateTracker.hasChanged()) {
// No changes, nothing to repaint.
outOfDateTime = 0;
return;
@@ -599,7 +599,7 @@
}
protected class SuspensionInfo {
- /**
+ /**
* The index of this redraw suspension
*/
int index;
@@ -653,21 +653,21 @@
* Sets up a timer that will trigger a repaint
* when it fires.
* If create is true it will construct a timer even
- * if one
+ * if one
*/
void resetRepaintTimer() {
if (repaintTimerTask == null) return;
if (allResumeTime < 0) return;
if (repaintTriggerTimer == null)
repaintTriggerTimer = new Timer(true);
-
+
long delay = allResumeTime - System.currentTimeMillis();
if (delay < 0) delay = 0;
repaintTimerTask = new RepaintTimerTask(this);
repaintTriggerTimer.schedule(repaintTimerTask, delay);
// System.err.println("Timer delay: " + delay);
}
-
+
int addRedrawSuspension(int max_wait_milliseconds) {
long resumeTime = System.currentTimeMillis() + max_wait_milliseconds;
SuspensionInfo si = new SuspensionInfo(nextSuspensionIndex++,
@@ -698,14 +698,14 @@
int idx = si.getIndex();
if (idx == index) { lo = hi = mid; }
else if (idx < index) { lo = mid+1; }
- else { hi = mid-1; }
+ else { hi = mid-1; }
}
SuspensionInfo si = (SuspensionInfo)suspensionList.get(lo);
int idx = si.getIndex();
- if (idx != index)
+ if (idx != index)
return true; // currently not in list but was at some point...
-
+
suspensionList.remove(lo);
if (suspensionList.size() == 0) {
// No more active suspensions
@@ -844,10 +844,10 @@
return new UpdateManagerRunHander();
}
- protected class UpdateManagerRunHander
+ protected class UpdateManagerRunHander
extends RunnableQueue.RunHandlerAdapter {
- public void runnableStart(RunnableQueue rq, Runnable r) {
+ public void runnableStart(RunnableQueue rq, Runnable r) {
if (running && !(r instanceof NoRepaintRunnable)) {
// Mark the document as updated when the
// runnable starts.
@@ -855,7 +855,7 @@
outOfDateTime = System.currentTimeMillis();
}
}
-
+
/**
* Called when the given Runnable has just been invoked and
@@ -866,7 +866,7 @@
repaint();
}
}
-
+
/**
* Called when the execution of the queue has been suspended.
*/
@@ -881,13 +881,13 @@
}
}
}
-
+
/**
* Called when the execution of the queue has been resumed.
*/
public void executionResumed(RunnableQueue rq) {
synchronized (UpdateManager.this) {
- // System.err.println("Resumed: " + suspendCalled +
+ // System.err.println("Resumed: " + suspendCalled +
// " : " + running);
if (suspendCalled && !running) {
running = true;