FileDocCategorySizeDatePackage
SomeArgs.javaAPI DocAndroid 5.1 API2829Thu Mar 12 22:22:10 GMT 2015com.android.internal.os

SomeArgs

public final class SomeArgs extends Object
Helper class for passing more arguments though a message and avoiding allocation of a custom class for wrapping the arguments. This class maintains a pool of instances and it is responsibility of the client to recycle and instance once it is no longer used.

Fields Summary
private static final int
MAX_POOL_SIZE
private static SomeArgs
sPool
private static int
sPoolSize
private static Object
sPoolLock
private SomeArgs
mNext
private boolean
mInPool
static final int
WAIT_NONE
static final int
WAIT_WAITING
static final int
WAIT_FINISHED
int
mWaitState
public Object
arg1
public Object
arg2
public Object
arg3
public Object
arg4
public Object
arg5
public Object
arg6
public int
argi1
public int
argi2
public int
argi3
public int
argi4
public int
argi5
public int
argi6
Constructors Summary
private SomeArgs()


      
        /* do nothing - reduce visibility */
    
Methods Summary
private voidclear()

        arg1 = null;
        arg2 = null;
        arg3 = null;
        arg4 = null;
        arg5 = null;
        arg6 = null;
        argi1 = 0;
        argi2 = 0;
        argi3 = 0;
        argi4 = 0;
        argi5 = 0;
        argi6 = 0;
    
public static com.android.internal.os.SomeArgsobtain()

        synchronized (sPoolLock) {
            if (sPoolSize > 0) {
                SomeArgs args = sPool;
                sPool = sPool.mNext;
                args.mNext = null;
                args.mInPool = false;
                sPoolSize--;
                return args;
            } else {
                return new SomeArgs();
            }
        }
    
public voidrecycle()

        if (mInPool) {
            throw new IllegalStateException("Already recycled.");
        }
        if (mWaitState != WAIT_NONE) {
            return;
        }
        synchronized (sPoolLock) {
            clear();
            if (sPoolSize < MAX_POOL_SIZE) {
                mNext = sPool;
                mInPool = true;
                sPool = this;
                sPoolSize++;
            }
        }