Restore a really single-threaded mode to DM.

Used to be:
   0 -> run on main thread plus an autodetected number of extra threads (default)
   N -> run on main thread plus N extra threads

Now it's:
  -1 -> run on main thread plus an autodetected number of extra threads (default)
   0 -> run on main thread
   N -> run on main thread plus N extra threads

BUG=skia:

Review URL: https://codereview.chromium.org/636593002
This commit is contained in:
mtklein 2014-10-06 11:24:08 -07:00 committed by Commit bot
parent 8e47478333
commit e356c7f0ee
3 changed files with 7 additions and 6 deletions

View File

@ -67,7 +67,7 @@ private:
};
explicit ThreadPool(int threads) : fDraining(false) {
if (threads == 0) {
if (threads == -1) {
threads = num_cores();
}
for (int i = 0; i < threads; i++) {
@ -133,11 +133,12 @@ ThreadPool* ThreadPool::gGlobal = NULL;
SkTaskGroup::Enabler::Enabler(int threads) {
SkASSERT(ThreadPool::gGlobal == NULL);
ThreadPool::gGlobal = SkNEW_ARGS(ThreadPool, (threads));
if (threads != 0) {
ThreadPool::gGlobal = SkNEW_ARGS(ThreadPool, (threads));
}
}
SkTaskGroup::Enabler::~Enabler() {
SkASSERT(ThreadPool::gGlobal != NULL);
SkDELETE(ThreadPool::gGlobal);
}

View File

@ -15,7 +15,7 @@ class SkTaskGroup : SkNoncopyable {
public:
// Create one of these in main() to enable SkTaskGroups globally.
struct Enabler : SkNoncopyable {
explicit Enabler(int threads = 0); // Default is system-reported core count.
explicit Enabler(int threads = -1); // Default is system-reported core count.
~Enabler();
};

View File

@ -43,8 +43,8 @@ DEFINE_bool(abandonGpuContext, false, "Abandon the GrContext after running each
DEFINE_string(skps, "skps", "Directory to read skps from.");
DEFINE_int32(threads, 0, "Run threadsafe tests on a threadpool with this many threads, "
"defaulting to one thread per core.");
DEFINE_int32(threads, -1, "Run threadsafe tests on a threadpool with this many extra threads, "
"defaulting to one extra thread per core.");
DEFINE_bool2(verbose, v, false, "enable verbose output from the test driver.");