FileDocCategorySizeDatePackage
RequestHandlerThread.javaAPI DocAndroid 5.1 API3456Thu Mar 12 22:22:10 GMT 2015android.hardware.camera2.legacy

RequestHandlerThread

public class RequestHandlerThread extends android.os.HandlerThread

Fields Summary
public static final int
MSG_POKE_IDLE_HANDLER
Ensure that the MessageQueue's idle handler gets run by poking the message queue; normally if the message queue is already idle, the idle handler won't get invoked.

Users of this handler thread should ignore this message.

private final android.os.ConditionVariable
mStarted
private final android.os.ConditionVariable
mIdle
private Handler.Callback
mCallback
private volatile android.os.Handler
mHandler
private final MessageQueue.IdleHandler
mIdleHandler
Constructors Summary
public RequestHandlerThread(String name, Handler.Callback callback)


         
        super(name, Thread.MAX_PRIORITY);
        mCallback = callback;
    
Methods Summary
public android.os.HandlergetHandler()

        return mHandler;
    
public booleanhasAnyMessages(int[] what)

        synchronized (mHandler.getLooper().getQueue()) {
            for (int i : what) {
                if (mHandler.hasMessages(i)) {
                    return true;
                }
            }
        }
        return false;
    
protected voidonLooperPrepared()

        mHandler = new Handler(getLooper(), mCallback);
        mStarted.open();
    
public voidremoveMessages(int[] what)

        synchronized (mHandler.getLooper().getQueue()) {
            for (int i : what) {
                mHandler.removeMessages(i);
            }
        }
    
public android.os.HandlerwaitAndGetHandler()

        waitUntilStarted();
        return getHandler();
    
public voidwaitUntilIdle()


    // Blocks until thread is idling
       
        Handler handler = waitAndGetHandler();
        Looper looper = handler.getLooper();
        if (looper.isIdling()) {
            return;
        }
        mIdle.close();
        looper.getQueue().addIdleHandler(mIdleHandler);
        // Ensure that the idle handler gets run even if the looper already went idle
        handler.sendEmptyMessage(MSG_POKE_IDLE_HANDLER);
        if (looper.isIdling()) {
            return;
        }
        mIdle.block();
    
public voidwaitUntilStarted()

        mStarted.block();