[Bf-blender-cvs] [7b51e97] openvdb: Cycles: avoid recomputing tread ids everytime we need them.

Kévin Dietrich noreply at git.blender.org
Sun Jan 17 21:26:34 CET 2016


Commit: 7b51e97617c26b1682f3d6e4dd51955b76f2496f
Author: Kévin Dietrich
Date:   Sun Jan 17 20:35:08 2016 +0100
Branches: openvdb
https://developer.blender.org/rB7b51e97617c26b1682f3d6e4dd51955b76f2496f

Cycles: avoid recomputing tread ids everytime we need them.

===================================================================

M	intern/cycles/util/util_task.cpp
M	intern/cycles/util/util_task.h

===================================================================

diff --git a/intern/cycles/util/util_task.cpp b/intern/cycles/util/util_task.cpp
index 2186c7c..d624db2 100644
--- a/intern/cycles/util/util_task.cpp
+++ b/intern/cycles/util/util_task.cpp
@@ -168,6 +168,7 @@ void TaskPool::num_increase()
 thread_mutex TaskScheduler::mutex;
 int TaskScheduler::users = 0;
 vector<thread*> TaskScheduler::threads;
+vector<pthread_t> TaskScheduler::threads_ids;
 bool TaskScheduler::do_exit = false;
 
 list<TaskScheduler::Entry> TaskScheduler::queue;
@@ -190,9 +191,12 @@ void TaskScheduler::init(int num_threads)
 
 		/* launch threads that will be waiting for work */
 		threads.resize(num_threads);
+		threads_ids.resize(num_threads);
 
-		for(size_t i = 0; i < threads.size(); i++)
+		for(size_t i = 0; i < threads.size(); i++) {
 			threads[i] = new thread(function_bind(&TaskScheduler::thread_run, i));
+			threads_ids.push_back(threads[i]->id());
+		}
 	}
 	
 	users++;
@@ -300,14 +304,7 @@ void TaskScheduler::clear(TaskPool *pool)
 
 vector<pthread_t> TaskScheduler::thread_ids()
 {
-	thread_scoped_lock lock(mutex);
-
-	vector<pthread_t> ids;
-	foreach(thread *t, threads) {
-		ids.push_back(t->id());
-	}
-
-	return ids;
+	return threads_ids;
 }
 
 /* Dedicated Task Pool */
diff --git a/intern/cycles/util/util_task.h b/intern/cycles/util/util_task.h
index e0e1f90..7e2eed3 100644
--- a/intern/cycles/util/util_task.h
+++ b/intern/cycles/util/util_task.h
@@ -112,6 +112,7 @@ protected:
 	static thread_mutex mutex;
 	static int users;
 	static vector<thread*> threads;
+	static vector<pthread_t> threads_ids;
 	static bool do_exit;
 
 	static list<Entry> queue;




More information about the Bf-blender-cvs mailing list