Query the CPU count and use the result to determine
if and how many worker threads we use.
Change-Id: I8fc1fb17aff835cfe8ed7c474287bccd532cbb29
diff --git a/libs/rs/rsContext.cpp b/libs/rs/rsContext.cpp
index e897d00..d6df581 100644
--- a/libs/rs/rsContext.cpp
+++ b/libs/rs/rsContext.cpp
@@ -468,8 +468,11 @@
timerInit();
timerSet(RS_TIMER_INTERNAL);
- LOGV("RS Launching thread(s)");
- mWorkers.mCount = 2;
+ int cpu = sysconf(_SC_NPROCESSORS_ONLN);
+ LOGV("RS Launching thread(s), reported CPU count %i", cpu);
+ if (cpu < 2) cpu = 0;
+
+ mWorkers.mCount = (uint32_t)cpu;
mWorkers.mThreadId = (pthread_t *) calloc(mWorkers.mCount, sizeof(pthread_t));
mWorkers.mNativeThreadId = (pid_t *) calloc(mWorkers.mCount, sizeof(pid_t));
mWorkers.mLaunchSignals = new Signal[mWorkers.mCount];