|
From: Elias N. <eli...@us...> - 2005-10-23 19:52:22
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4752/src/java/org/lwjgl/opengl Modified Files: PeerInfo.java Log Message: Don't fail on two threads wanting to lock the same PeerInfo Index: PeerInfo.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/PeerInfo.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- PeerInfo.java 4 May 2005 20:59:36 -0000 1.4 +++ PeerInfo.java 23 Oct 2005 19:52:15 -0000 1.5 @@ -34,6 +34,7 @@ import java.nio.ByteBuffer; import org.lwjgl.LWJGLException; +import org.lwjgl.LWJGLUtil; /** * $Id$ @@ -63,6 +64,7 @@ if (lock_count == 0) { doUnlock(); locking_thread = null; + notify(); } } @@ -71,8 +73,13 @@ public synchronized final ByteBuffer lockAndGetHandle() throws LWJGLException { Thread this_thread = Thread.currentThread(); - if (locking_thread != null && locking_thread != this_thread) - throw new IllegalStateException("PeerInfo already locked by " + locking_thread); + while (locking_thread != null && locking_thread != this_thread) { + try { + wait(); + } catch (InterruptedException e) { + LWJGLUtil.log("Interrupted while waiting for PeerInfo lock: " + e); + } + } if (lock_count == 0) { locking_thread = this_thread; doLockAndInitHandle(); |