From 134de4472d3f2fa913944770595de9221dd27fdf Mon Sep 17 00:00:00 2001 From: Thomas B Thompson Date: Tue, 4 Jan 2011 00:04:05 -0500 Subject: worked on profiling, made a bunch of changes, huge speedup! --- operationscore/Input.py | 3 ++- operationscore/Renderer.py | 4 ++-- operationscore/SmootCoreObject.py | 3 +-- operationscore/ThreadedSmootCoreObject.py | 14 ++++++++++++++ 4 files changed, 19 insertions(+), 5 deletions(-) create mode 100644 operationscore/ThreadedSmootCoreObject.py (limited to 'operationscore') diff --git a/operationscore/Input.py b/operationscore/Input.py index 62c4682..6b56cd5 100644 --- a/operationscore/Input.py +++ b/operationscore/Input.py @@ -1,5 +1,6 @@ import threading,time from operationscore.SmootCoreObject import * +from operationscore.ThreadedSmootCoreObject import ThreadedSmootCoreObject #Abstract class for inputs. Inheriting classes should call "respond" to raise #their event. Inheriting classes MUST define sensingLoop. Called at the #interval specified in RefreshInterval while the input is active. For example, if you are writing @@ -7,7 +8,7 @@ from operationscore.SmootCoreObject import * #Inheriting classes MAY define inputInit. This is called before the loop #begins. import pdb -class Input(SmootCoreObject): +class Input(ThreadedSmootCoreObject): #Event scope is a function pointer the function that will get called when #an Parent is raised. def __init__(self, argDict): diff --git a/operationscore/Renderer.py b/operationscore/Renderer.py index 8e31f8b..88da606 100644 --- a/operationscore/Renderer.py +++ b/operationscore/Renderer.py @@ -3,8 +3,8 @@ #Inheriting classes may define initRenderer which is called after the dictionary #is pulled from config. #TODO: multithreaded-rendering -from operationscore.SmootCoreObject import * -class Renderer(SmootCoreObject): +from operationscore.ThreadedSmootCoreObject import * +class Renderer(ThreadedSmootCoreObject): def init(self): self.initRenderer() threading.Thread.__init__(self) diff --git a/operationscore/SmootCoreObject.py b/operationscore/SmootCoreObject.py index 9784aab..7e3c8bd 100644 --- a/operationscore/SmootCoreObject.py +++ b/operationscore/SmootCoreObject.py @@ -2,12 +2,11 @@ import pdb import threading import thread import util.Config as configGetter -class SmootCoreObject(threading.Thread): +class SmootCoreObject(object): def __init__(self, argDict, skipValidation = False): self.argDict = argDict self.validateArgs(self.className()+'.params') self.lock = thread.allocate_lock() - threading.Thread.__init__(self) self.init() #call init of inheriting class # self.__setitem__ = self.argDict.__setitem__ # self.__getitem__ = self.argDict.__getitem__ diff --git a/operationscore/ThreadedSmootCoreObject.py b/operationscore/ThreadedSmootCoreObject.py new file mode 100644 index 0000000..90611bc --- /dev/null +++ b/operationscore/ThreadedSmootCoreObject.py @@ -0,0 +1,14 @@ +import pdb +import threading +import thread +import util.Config as configGetter +from operationscore.SmootCoreObject import SmootCoreObject +class ThreadedSmootCoreObject(SmootCoreObject, threading.Thread): + def __init__(self, argDict, skipValidation = False): + self.argDict = argDict + self.validateArgs(self.className()+'.params') + self.lock = thread.allocate_lock() + threading.Thread.__init__(self) + self.init() #call init of inheriting class + # self.__setitem__ = self.argDict.__setitem__ + # self.__getitem__ = self.argDict.__getitem__ -- cgit v1.2.3