mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-02-01 19:57:11 +01:00
log GameLock failure only when it's a result
This commit is contained in:
parent
4c9ded77bf
commit
20359e50da
1 changed files with 20 additions and 9 deletions
|
@ -22,6 +22,7 @@ package org.eehouse.android.xw4;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
|
import java.util.Formatter;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Stack;
|
import java.util.Stack;
|
||||||
|
@ -114,13 +115,6 @@ public class GameLock implements AutoCloseable {
|
||||||
mReadOnly = readOnly;
|
mReadOnly = readOnly;
|
||||||
result = this;
|
result = this;
|
||||||
}
|
}
|
||||||
if ( DEBUG_LOCKS ) {
|
|
||||||
Log.d( TAG, "%s.tryLockImpl(ro=%b) => %s", this, readOnly, result );
|
|
||||||
if ( null == result ) {
|
|
||||||
Log.d( TAG, "Unable to lock; cur owner: %s; would-be owner: %s",
|
|
||||||
mOwners.peek(), new Owner() );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -129,12 +123,16 @@ public class GameLock implements AutoCloseable {
|
||||||
// // see if not doing that causes problems.
|
// // see if not doing that causes problems.
|
||||||
public GameLock tryLock()
|
public GameLock tryLock()
|
||||||
{
|
{
|
||||||
return tryLockImpl( false );
|
GameLock result = tryLockImpl( false );
|
||||||
|
logIfNull( result, "tryLock()" );
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public GameLock tryLockRO()
|
public GameLock tryLockRO()
|
||||||
{
|
{
|
||||||
return tryLockImpl( true );
|
GameLock result = tryLockImpl( true );
|
||||||
|
logIfNull( result, "tryLockRO()" );
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private GameLock lockImpl( long timeoutMS, boolean readOnly ) throws InterruptedException
|
private GameLock lockImpl( long timeoutMS, boolean readOnly ) throws InterruptedException
|
||||||
|
@ -182,6 +180,7 @@ public class GameLock implements AutoCloseable {
|
||||||
if ( DEBUG_LOCKS ) {
|
if ( DEBUG_LOCKS ) {
|
||||||
Log.d( TAG, "%s.lock(%d) => %s", this, maxMillis, result );
|
Log.d( TAG, "%s.lock(%d) => %s", this, maxMillis, result );
|
||||||
}
|
}
|
||||||
|
logIfNull( result, "lock(maxMillis=%d)", maxMillis );
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,6 +192,8 @@ public class GameLock implements AutoCloseable {
|
||||||
lock = lockImpl( maxMillis, true );
|
lock = lockImpl( maxMillis, true );
|
||||||
} catch ( InterruptedException ex ) {
|
} catch ( InterruptedException ex ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logIfNull( lock, "lockRO(maxMillis=%d)", maxMillis );
|
||||||
return lock;
|
return lock;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -240,4 +241,14 @@ public class GameLock implements AutoCloseable {
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void logIfNull( GameLock result, String fmt, Object... args )
|
||||||
|
{
|
||||||
|
if ( DEBUG_LOCKS && null == result ) {
|
||||||
|
String func = new Formatter().format( fmt, args ).toString();
|
||||||
|
Log.d( TAG, "%s.%s => null", this, func );
|
||||||
|
Log.d( TAG, "Unable to lock; cur owner: %s; would-be owner: %s",
|
||||||
|
mOwners.peek(), new Owner() );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue