summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
authorU. Artie Eoff <ullysses.a.eoff@intel.com>2011-02-12 12:07:05 -0800
committerChad Versace <chad.versace@intel.com>2011-02-17 08:08:42 -0800
commitf7bb43f3a9c8bb5dbe40908c5b924f5f51bd7d06 (patch)
tree6da8af54b7d4ffc0dbc514daf3d4dbe05842e7d6 /framework
parente8c39dc78b7b123a0e83261167b41ceaddd3f3a6 (diff)
Add ConcurrentTestPool singleton.
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. Reviewed-by: Chad Versace <chad.versace@intel.com>
Diffstat (limited to 'framework')
-rw-r--r--framework/threads.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/framework/threads.py b/framework/threads.py
index edd7eded2..2613c38be 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):