From d10c7916a2444b6cb1cf45be3ccb3d6e91a2f1b4 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 29 Jun 2012 04:09:48 +0200 Subject: NativeSurface.unlockSurface(): Change fail-fast policy to fail safe tolerant - This policy allows more simple destruction handling w/o validating on the top level. - Hence 'unlockSurface()' shall not throw any exception. - 'lockSurface()' keeps unchanges, clarified w/ explicit 'throws' declaration, ie will fail-fast. --- .../classes/javax/media/nativewindow/NativeSurface.java | 8 +++++--- .../classes/javax/media/nativewindow/ProxySurface.java | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'src/nativewindow/classes/javax') diff --git a/src/nativewindow/classes/javax/media/nativewindow/NativeSurface.java b/src/nativewindow/classes/javax/media/nativewindow/NativeSurface.java index c58b34b18..cec7d4ec3 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/NativeSurface.java +++ b/src/nativewindow/classes/javax/media/nativewindow/NativeSurface.java @@ -83,10 +83,11 @@ public interface NativeSurface extends SurfaceUpdatedListener { * @return {@link #LOCK_SUCCESS}, {@link #LOCK_SURFACE_CHANGED} or {@link #LOCK_SURFACE_NOT_READY}. * * @throws RuntimeException after timeout when waiting for the surface lock + * @throws NativeWindowException if native locking failed, maybe platform related * * @see com.jogamp.common.util.locks.RecursiveLock */ - public int lockSurface(); + public int lockSurface() throws NativeWindowException, RuntimeException; /** * Unlock the surface of this native window @@ -96,12 +97,13 @@ public interface NativeSurface extends SurfaceUpdatedListener { * The implementation shall also invoke {@link AbstractGraphicsDevice#unlock()} * for the final unlock (recursive count zero).

* - * @throws RuntimeException if surface is not locked + * The implementation shall be fail safe, i.e. tolerant in case the native resources + * are already released / unlocked. In this case the implementation shall simply ignore the call. * * @see #lockSurface * @see com.jogamp.common.util.locks.RecursiveLock */ - public void unlockSurface() throws NativeWindowException ; + public void unlockSurface(); /** * Query if surface is locked by another thread, i.e. not the current one. diff --git a/src/nativewindow/classes/javax/media/nativewindow/ProxySurface.java b/src/nativewindow/classes/javax/media/nativewindow/ProxySurface.java index c8cd78d82..1dabc3dcd 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/ProxySurface.java +++ b/src/nativewindow/classes/javax/media/nativewindow/ProxySurface.java @@ -123,7 +123,7 @@ public abstract class ProxySurface implements NativeSurface { } @Override - public int lockSurface() throws NativeWindowException { + public int lockSurface() throws NativeWindowException, RuntimeException { surfaceLock.lock(); int res = surfaceLock.getHoldCount() == 1 ? LOCK_SURFACE_NOT_READY : LOCK_SUCCESS; // new lock ? -- cgit v1.2.3