diff options
Diffstat (limited to 'libs/hwui/thread')
-rw-r--r-- | libs/hwui/thread/Task.h | 4 | ||||
-rw-r--r-- | libs/hwui/thread/TaskManager.cpp | 16 | ||||
-rw-r--r-- | libs/hwui/thread/TaskManager.h | 1 |
3 files changed, 16 insertions, 5 deletions
diff --git a/libs/hwui/thread/Task.h b/libs/hwui/thread/Task.h index 9a211a2..30b6ff2 100644 --- a/libs/hwui/thread/Task.h +++ b/libs/hwui/thread/Task.h @@ -17,8 +17,6 @@ #ifndef ANDROID_HWUI_TASK_H #define ANDROID_HWUI_TASK_H -#define ATRACE_TAG ATRACE_TAG_VIEW - #include <utils/RefBase.h> #include <utils/Trace.h> @@ -40,7 +38,7 @@ public: virtual ~Task() { } T getResult() const { - ATRACE_NAME("waitForTask"); + ScopedTrace tracer(ATRACE_TAG_VIEW, "waitForTask"); return mFuture->get(); } diff --git a/libs/hwui/thread/TaskManager.cpp b/libs/hwui/thread/TaskManager.cpp index 189895c..cb5401c 100644 --- a/libs/hwui/thread/TaskManager.cpp +++ b/libs/hwui/thread/TaskManager.cpp @@ -15,10 +15,14 @@ */ #include <sys/sysinfo.h> +#if defined(HAVE_PTHREADS) +#include <sys/resource.h> +#endif +#include "TaskManager.h" #include "Task.h" #include "TaskProcessor.h" -#include "TaskManager.h" +#include "utils/MathUtils.h" namespace android { namespace uirenderer { @@ -31,7 +35,8 @@ TaskManager::TaskManager() { // Get the number of available CPUs. This value does not change over time. int cpuCount = sysconf(_SC_NPROCESSORS_CONF); - for (int i = 0; i < cpuCount / 2; i++) { + int workerCount = MathUtils::max(1, cpuCount / 2); + for (int i = 0; i < workerCount; i++) { String8 name; name.appendFormat("hwuiTask%d", i + 1); mThreads.add(new WorkerThread(name)); @@ -77,6 +82,13 @@ bool TaskManager::addTaskBase(const sp<TaskBase>& task, const sp<TaskProcessorBa // Thread /////////////////////////////////////////////////////////////////////////////// +status_t TaskManager::WorkerThread::readyToRun() { +#if defined(HAVE_PTHREADS) + setpriority(PRIO_PROCESS, 0, PRIORITY_FOREGROUND); +#endif + return NO_ERROR; +} + bool TaskManager::WorkerThread::threadLoop() { mSignal.wait(); Vector<TaskWrapper> tasks; diff --git a/libs/hwui/thread/TaskManager.h b/libs/hwui/thread/TaskManager.h index f2a216f..5a933ab 100644 --- a/libs/hwui/thread/TaskManager.h +++ b/libs/hwui/thread/TaskManager.h @@ -84,6 +84,7 @@ private: void exit(); private: + virtual status_t readyToRun(); virtual bool threadLoop(); // Lock for the list of tasks |