Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b14e42f1 authored by Dianne Hackborn's avatar Dianne Hackborn Committed by Android (Google) Code Review
Browse files

Merge "Cleanup some of the thread merging."

parents 203a91a6 efa92b21
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -94,12 +94,12 @@ extern "C" status_t system_init()
    if (methodId == NULL) {
        return UNKNOWN_ERROR;
    }
    env->CallStaticVoidMethod(clazz, methodId);

    ALOGI("System server: entering thread pool.\n");
    ALOGI("System server: entering thread pool.");
    ProcessState::self()->startThreadPool();
    IPCThreadState::self()->joinThreadPool();
    ALOGI("System server: exiting thread pool.\n");

    // This is the main thread of the system server, and will never exit.
    env->CallStaticVoidMethod(clazz, methodId);

    return NO_ERROR;
}
+10 −0
Original line number Diff line number Diff line
@@ -289,6 +289,16 @@ public final class Looper {
        return mQueue;
    }

    /**
     * Return whether this looper's thread is currently idle, waiting for new work
     * to do.  This is intrinsically racy, since its state can change before you get
     * the result back.
     * @hide
     */
    public boolean isIdling() {
        return mQueue.isIdling();
    }

    public void dump(Printer pw, String prefix) {
        pw = PrefixPrinter.create(pw, prefix);
        pw.println(this.toString());
+5 −0
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@ public final class MessageQueue {
    private native static void nativeDestroy(int ptr);
    private native static void nativePollOnce(int ptr, int timeoutMillis);
    private native static void nativeWake(int ptr);
    private native static boolean nativeIsIdling(int ptr);

    /**
     * Callback interface for discovering when a thread is going to block
@@ -379,6 +380,10 @@ public final class MessageQueue {
        }
    }

    boolean isIdling() {
        return nativeIsIdling(mPtr);
    }

    void removeMessages(Handler h, int what, Object object) {
        if (h == null) {
            return;
+7 −1
Original line number Diff line number Diff line
@@ -141,6 +141,11 @@ static void android_os_MessageQueue_nativeWake(JNIEnv* env, jclass clazz, jint p
    return nativeMessageQueue->wake();
}

static jboolean android_os_MessageQueue_nativeIsIdling(JNIEnv* env, jclass clazz, jint ptr) {
    NativeMessageQueue* nativeMessageQueue = reinterpret_cast<NativeMessageQueue*>(ptr);
    return nativeMessageQueue->getLooper()->isIdling();
}

// ----------------------------------------------------------------------------

static JNINativeMethod gMessageQueueMethods[] = {
@@ -148,7 +153,8 @@ static JNINativeMethod gMessageQueueMethods[] = {
    { "nativeInit", "()I", (void*)android_os_MessageQueue_nativeInit },
    { "nativeDestroy", "(I)V", (void*)android_os_MessageQueue_nativeDestroy },
    { "nativePollOnce", "(II)V", (void*)android_os_MessageQueue_nativePollOnce },
    { "nativeWake", "(I)V", (void*)android_os_MessageQueue_nativeWake }
    { "nativeWake", "(I)V", (void*)android_os_MessageQueue_nativeWake },
    { "nativeIsIdling", "(I)Z", (void*)android_os_MessageQueue_nativeIsIdling }
};

#define FIND_CLASS(var, className) \
+2 −2
Original line number Diff line number Diff line
@@ -47,14 +47,14 @@ public final class IoThread extends HandlerThread {
    }

    public static IoThread get() {
        synchronized (UiThread.class) {
        synchronized (IoThread.class) {
            ensureThreadLocked();
            return sInstance;
        }
    }

    public static Handler getHandler() {
        synchronized (UiThread.class) {
        synchronized (IoThread.class) {
            ensureThreadLocked();
            return sHandler;
        }
Loading