diff options
author | Sven Gothel <[email protected]> | 2012-05-13 20:00:21 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2012-05-13 22:05:35 +0200 |
commit | df6c9accd84b801d86c8f6f9ce35e02ffd417f71 (patch) | |
tree | 9dd593bf6ed9631ef8ac723b5e07c87ae3e347d7 /src/jogl/classes/javax/media/opengl | |
parent | 78d9e7c84f03ac7b83ad2933cac884ce9ecac161 (diff) |
GLContext*: Remove '[set/is]Synchronized(..)' - Defaults to wait for locks: 1. Drawable, 2. GLContext
Remove deadlock situation where thread-1 (Animator Thread) holds the GLContext-Lock
and acquires the Surface-Lock, while thread-2 (UI/Main/EDT) holds the Surface-Lock
and attempts to create the GLContext and hence acquires the GLContext-Lock.
A GLContext-Lock and hence makeing the GLContext current requires to hold
the Surface-Lock. The prev. code acquired the locks in reverse order and
allowed the deadlock as described above.
This fix acquires the locks in the proper natural order
1 - Surface-Lock
2 - GLContext-Lock
This fix also renders the use of the non-synchronized behavior invalid,
since it is bogus not to wait for the GLContext lock where it waits for the
Surface lock. It also seems nonsense not to wait for any of both locks
and our code always waited for both (synchronized := true).
The GLContext [set/is]Synchronized(..) methods are removed
and waiting for the lock per default is the correct behavior.
Diffstat (limited to 'src/jogl/classes/javax/media/opengl')
-rw-r--r-- | src/jogl/classes/javax/media/opengl/GLContext.java | 10 | ||||
-rw-r--r-- | src/jogl/classes/javax/media/opengl/awt/GLCanvas.java | 1 | ||||
-rw-r--r-- | src/jogl/classes/javax/media/opengl/awt/GLJPanel.java | 3 |
3 files changed, 0 insertions, 14 deletions
diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java index 815da277c..e23fa74f9 100644 --- a/src/jogl/classes/javax/media/opengl/GLContext.java +++ b/src/jogl/classes/javax/media/opengl/GLContext.java @@ -319,16 +319,6 @@ public abstract class GLContext { public abstract void destroy(); /** - * Returns true if 'makeCurrent' will exhibit synchronized behavior. - */ - public abstract boolean isSynchronized(); - - /** - * Determines whether 'makeCurrent' will exhibit synchronized behavior. - */ - public abstract void setSynchronized(boolean isSynchronized); - - /** * Returns the GL pipeline object for this GLContext. * * @return the aggregated GL instance, or null if this context was not yet made current. diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java index a8d3c03a8..0d32655b9 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java @@ -541,7 +541,6 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing try { drawable = GLDrawableFactory.getFactory(capsReqUser.getGLProfile()).createGLDrawable(jawtWindow); context = (GLContextImpl) drawable.createContext(shareWith); - context.setSynchronized(true); context.setContextCreationFlags(additionalCtxCreationFlags); } finally { jawtWindow.unlockSurface(); diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java index db3f189cb..167b99374 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java @@ -974,7 +974,6 @@ public void reshape(int x, int y, int width, int height) { Math.max(1, panelHeight)); offscreenDrawable.setRealized(true); offscreenContext = (GLContextImpl) offscreenDrawable.createContext(shareWith); - offscreenContext.setSynchronized(true); offscreenContext.setContextCreationFlags(additionalCtxCreationFlags); isInitialized = true; @@ -1600,7 +1599,6 @@ public void reshape(int x, int y, int width, int height) { if (factory.canCreateExternalGLDrawable(device)) { joglDrawable = factory.createExternalGLDrawable(); joglContext = joglDrawable.createContext(j2dContext); - joglContext.setSynchronized(true); if (DEBUG) { System.err.println("-- Created External Drawable: "+joglDrawable); System.err.println("-- Created Context: "+joglContext); @@ -1608,7 +1606,6 @@ public void reshape(int x, int y, int width, int height) { } else if (factory.canCreateContextOnJava2DSurface(device)) { // Mac OS X code path joglContext = factory.createContextOnJava2DSurface(g, j2dContext); - joglContext.setSynchronized(true); if (DEBUG) { System.err.println("-- Created Context: "+joglContext); } |