[Piglit] [PATCH 1/4] Add ConcurrentTestPool singleton.

U. Artie Eoff ullysses.a.eoff at intel.com
Sat Feb 12 12:07:05 PST 2011


The ConcurrentTestPool singleton will simplify the threading model
and remove the need to manage multiple ThreadPools.  Only one
threadpool is currently needed at this time and is meant to execute
cpu-only tests in separate threads.
---
 framework/threads.py |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/framework/threads.py b/framework/threads.py
index edd7ede..2613c38 100644
--- a/framework/threads.py
+++ b/framework/threads.py
@@ -41,6 +41,22 @@ def synchronized_self(function):
 
 synchronized_self.locks = WeakKeyDictionary() # track the locks for each instance
 
+class ConcurrentTestPool(Singleton):
+	@synchronized_self
+	def init(self):
+		self.pool = ThreadPool(2)
+
+	@synchronized_self
+	def put(self, callable_, args = None, kwds = None):
+		self.pool.putRequest(
+			WorkRequest(
+				callable_, args = args, kwds = kwds
+			)
+		)
+
+	def join(self):
+		self.pool.wait()
+
 class ThreadPools(Singleton):
 	@synchronized_self
 	def init(self):
-- 
1.7.3.4



More information about the Piglit mailing list