OSDN Git Service

Framework-side support for Dalvik "isSensitiveThread" hook.
authorBrad Fitzpatrick <bradfitz@android.com>
Tue, 14 Dec 2010 00:52:35 +0000 (16:52 -0800)
committerBrad Fitzpatrick <bradfitz@android.com>
Tue, 14 Dec 2010 17:28:16 +0000 (09:28 -0800)
Used in lock contention stats.

Bug: 3226270
Change-Id: Ie6f58d130a29079a59bdefad40b80304d9bc3623

include/binder/IPCThreadState.h
libs/binder/IPCThreadState.cpp

index b54718f..3378d97 100644 (file)
@@ -33,6 +33,7 @@ class IPCThreadState
 {
 public:
     static  IPCThreadState*     self();
+    static  IPCThreadState*     selfOrNull();  // self(), but won't instantiate
     
             sp<ProcessState>    process();
             
index 13c58f0..95cfddf 100644 (file)
@@ -318,6 +318,16 @@ restart:
     goto restart;
 }
 
+IPCThreadState* IPCThreadState::selfOrNull()
+{
+    if (gHaveTLS) {
+        const pthread_key_t k = gTLS;
+        IPCThreadState* st = (IPCThreadState*)pthread_getspecific(k);
+        return st;
+    }
+    return NULL;
+}
+
 void IPCThreadState::shutdown()
 {
     gShutdown = true;