[Avida-cvs] [Avida2-svn] r91 -
branches/developers/kaben/source/python/AvidaGui2
kaben at myxo.css.msu.edu
kaben at myxo.css.msu.edu
Wed Mar 30 11:41:25 PST 2005
Author: kaben
Date: 2005-03-30 14:41:25 -0500 (Wed, 30 Mar 2005)
New Revision: 91
Modified:
branches/developers/kaben/source/python/AvidaGui2/pyAvida.py
branches/developers/kaben/source/python/AvidaGui2/pyAvidaThreadedDriver.py
Log:
* Experiment to move some gui work into the processing thread.
Modified: branches/developers/kaben/source/python/AvidaGui2/pyAvida.py
===================================================================
--- branches/developers/kaben/source/python/AvidaGui2/pyAvida.py 2005-03-30 19:33:03 UTC (rev 90)
+++ branches/developers/kaben/source/python/AvidaGui2/pyAvida.py 2005-03-30 19:41:25 UTC (rev 91)
@@ -78,6 +78,12 @@
return self
+ def addGuiWorkFunctor(self, thread_work_functor):
+ self.m_avida_threaded_driver.addGuiWorkFunctor(thread_work_functor)
+
+ def removeGuiWorkFunctor(self, thread_work_functor):
+ self.m_avida_threaded_driver.removeGuiWorkFunctor(thread_work_functor)
+
def destruct(self):
self.m_avida_thread_mdtr.emit(qt.PYSIGNAL("doCloseAvidaSig"),())
if hasattr(self, "m_update_ck_timer"):
Modified: branches/developers/kaben/source/python/AvidaGui2/pyAvidaThreadedDriver.py
===================================================================
--- branches/developers/kaben/source/python/AvidaGui2/pyAvidaThreadedDriver.py 2005-03-30 19:33:03 UTC (rev 90)
+++ branches/developers/kaben/source/python/AvidaGui2/pyAvidaThreadedDriver.py 2005-03-30 19:41:25 UTC (rev 91)
@@ -28,6 +28,8 @@
# to exit, preventing the python process from exiting.
atexit.register(self.__del__)
+ self.m_work_functors = []
+
pass
def __del__(self):
@@ -48,6 +50,14 @@
self.m_lock.acquire()
# continue update.
self.m_updating = self.ProcessSome(self.m_process_bitesize)
+ # do work on behalf of gui.
+ for work_functor in self.m_work_functors:
+ functor_still_working = True
+ while functor_still_working:
+ self.m_lock.release()
+ self.m_lock.acquire()
+ functor_still_working = work_functor.doSomeWork(self)
+
self.m_lock.release()
# tell other threads that an update has completed (possibly
# unsuccessfully).
@@ -55,6 +65,16 @@
if self.getDoneFlag():
return
+ def addGuiWorkFunctor(self, thread_work_functor):
+ self.m_lock.acquire()
+ self.m_work_functors.append(thread_work_functor)
+ self.m_lock.release()
+
+ def removeGuiWorkFunctor(self, thread_work_functor):
+ self.m_lock.acquire()
+ self.m_work_functors.remove(thread_work_functor)
+ self.m_lock.release()
+
def doExit(self):
print("pyAvidaThreadedDriver.doExit()...")
self.m_lock.acquire()
@@ -64,9 +84,7 @@
print("pyAvidaThreadedDriver.doExit() done.")
def doUpdate(self):
- print("pyAvidaThreadedDriver.doUpdate()...")
self.m_do_update_semaphore.release()
- print("pyAvidaThreadedDriver.doUpdate() done.")
def doSetProcessBitesize(self, bitesize):
self.m_lock.acquire()
More information about the Avida-cvs
mailing list