Commit f7bb43f3 authored by U. Artie Eoff's avatar U. Artie Eoff Committed by Chad Versace
Browse files

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: default avatarChad Versace <chad.versace@intel.com>
parent e8c39dc7
...@@ -41,6 +41,22 @@ def synchronized_self(function): ...@@ -41,6 +41,22 @@ def synchronized_self(function):
synchronized_self.locks = WeakKeyDictionary() # track the locks for each instance 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): class ThreadPools(Singleton):
@synchronized_self @synchronized_self
def init(self): def init(self):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment