remove logging around GameLock

This commit is contained in:
Andy2 2011-03-04 18:53:47 -08:00
parent 997365bc20
commit b0b747f642

View file

@ -48,7 +48,7 @@ public class GameUtils {
private String m_path; private String m_path;
private boolean m_isForWrite; private boolean m_isForWrite;
private int m_lockCount; private int m_lockCount;
StackTraceElement[] m_lockTrace; // StackTraceElement[] m_lockTrace;
// This will leak empty ReentrantReadWriteLock instances for // This will leak empty ReentrantReadWriteLock instances for
// now. // now.
@ -60,8 +60,8 @@ public class GameUtils {
m_path = path; m_path = path;
m_isForWrite = isForWrite; m_isForWrite = isForWrite;
m_lockCount = 0; m_lockCount = 0;
Utils.logf( "GameLock.GameLock(%s,%s) done", m_path, // Utils.logf( "GameLock.GameLock(%s,%s) done", m_path,
m_isForWrite?"T":"F" ); // m_isForWrite?"T":"F" );
} }
// This could be written to allow multiple read locks. Let's // This could be written to allow multiple read locks. Let's
@ -77,10 +77,10 @@ public class GameUtils {
++m_lockCount; ++m_lockCount;
gotIt = true; gotIt = true;
StackTraceElement[] trace = Thread.currentThread(). // StackTraceElement[] trace = Thread.currentThread().
getStackTrace(); // getStackTrace();
m_lockTrace = new StackTraceElement[trace.length]; // m_lockTrace = new StackTraceElement[trace.length];
System.arraycopy( trace, 0, m_lockTrace, 0, trace.length ); // System.arraycopy( trace, 0, m_lockTrace, 0, trace.length );
} else if ( this == owner && ! m_isForWrite ) { } else if ( this == owner && ! m_isForWrite ) {
Assert.assertTrue( 0 == m_lockCount ); Assert.assertTrue( 0 == m_lockCount );
++m_lockCount; ++m_lockCount;
@ -93,13 +93,13 @@ public class GameUtils {
public GameLock lock() public GameLock lock()
{ {
long stopTime = System.currentTimeMillis() + 1000; long stopTime = System.currentTimeMillis() + 1000;
Utils.logf( "GameLock.lock(%s)", m_path ); // Utils.logf( "GameLock.lock(%s)", m_path );
// Utils.printStack(); // Utils.printStack();
for ( ; ; ) { for ( ; ; ) {
if ( tryLock() ) { if ( tryLock() ) {
break; break;
} }
Utils.logf( "GameLock.lock() failed; sleeping" ); // Utils.logf( "GameLock.lock() failed; sleeping" );
// Utils.printStack(); // Utils.printStack();
try { try {
Thread.sleep( 25 ); // milliseconds Thread.sleep( 25 ); // milliseconds
@ -108,17 +108,17 @@ public class GameUtils {
break; break;
} }
if ( System.currentTimeMillis() >= stopTime ) { if ( System.currentTimeMillis() >= stopTime ) {
Utils.printStack( m_lockTrace ); // Utils.printStack( m_lockTrace );
Assert.fail(); Assert.fail();
} }
} }
Utils.logf( "GameLock.lock(%s) done", m_path ); // Utils.logf( "GameLock.lock(%s) done", m_path );
return this; return this;
} }
public void unlock() public void unlock()
{ {
Utils.logf( "GameLock.unlock(%s)", m_path ); // Utils.logf( "GameLock.unlock(%s)", m_path );
synchronized( s_locks ) { synchronized( s_locks ) {
Assert.assertTrue( this == s_locks.get(m_path) ); Assert.assertTrue( this == s_locks.get(m_path) );
if ( 1 == m_lockCount ) { if ( 1 == m_lockCount ) {
@ -128,7 +128,7 @@ public class GameUtils {
} }
--m_lockCount; --m_lockCount;
} }
Utils.logf( "GameLock.unlock(%s) done", m_path ); // Utils.logf( "GameLock.unlock(%s) done", m_path );
} }
public String getPath() public String getPath()