- Added still more error checking to PythonCPUPolicy. But the code which calls its methods should be updated to handle the new exceptions...

- Added a base class for cpu policy exceptions to make simpler their catching
- Implemented all numeric fields in dialogs with spinboxes, with bounds checking

git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@838 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
elvez 2006-08-10 00:42:17 +00:00
parent d3c7b46853
commit 48fc2f5a00
18 changed files with 298 additions and 177 deletions

View file

@ -1,4 +1,4 @@
import mutex, thread
import sys, mutex, thread
import sgpem
## @brief This is an adapter class which acts as a proxy
@ -26,6 +26,8 @@ class ScriptAdapter :
## Var Testable syncronization object
_g_mutex = mutex.mutex()
_g_last_exception = None
## @brief Constructor of ScriptAdapter
#
# @param self The caller object
@ -38,15 +40,19 @@ class ScriptAdapter :
#
# @param self The caller object
def async_configure(self):
self._g_mutex.lock(ScriptAdapter._wrap_configure, self )
self._g_last_exception = None
self._g_mutex.lock(ScriptAdapter._wrap_configure, self )
def _wrap_configure(self):
thread.start_new_thread(ScriptAdapter._wrap_configure_callback, (self,))
def _wrap_configure_callback(self):
# call configure method
self._policy.configure()
self._g_mutex.unlock()
try:
self._policy.configure()
except:
self._g_last_exception = sys.exc_value
self._g_mutex.unlock()
## @brief Asynchronously call Policy.sort_queue()
@ -56,6 +62,7 @@ class ScriptAdapter :
#
# @param self The caller object
def async_sort_queue(self):
self._g_last_exception = None
self._g_mutex.lock(ScriptAdapter._wrap_sort_queue, self)
def _wrap_sort_queue(self):
@ -64,7 +71,11 @@ class ScriptAdapter :
def _wrap_sort_queue_callback(self):
# here we retrieve and pass the ready queue
queue = sgpem.Scheduler.get_instance().get_ready_queue()
self._policy.sort_queue(queue)
try:
self._policy.sort_queue(queue)
except:
self._g_last_exception = sys.exc_value
self._g_mutex.unlock()
@ -72,26 +83,34 @@ class ScriptAdapter :
#
# @param self The caller object
def async_is_preemptive(self):
self._g_last_exception = None
self._g_mutex.lock(ScriptAdapter._wrap_is_preemptive, self)
def _wrap_is_preemptive(self):
thread.start_new_thread(ScriptAdapter._wrap_is_preemptive_callback, (self,))
def _wrap_is_preemptive_callback(self):
self._ret_val = self._policy.is_preemptive()
try:
self._ret_val = self._policy.is_preemptive()
except:
self._g_last_exception = sys.exc_value
self._g_mutex.unlock()
## @brief Asynchronously call Policy.get_time_slice()
#
# @param self The caller object
def async_get_time_slice(self):
self._g_last_exception = None
self._g_mutex.lock(ScriptAdapter._wrap_get_time_slice, self)
def _wrap_get_time_slice(self):
thread.start_new_thread(ScriptAdapter._wrap_get_time_slice_callback, (self,))
def _wrap_get_time_slice_callback(self):
self._ret_val = self._policy.get_time_slice()
try:
self._ret_val = self._policy.get_time_slice()
except:
self._g_last_exception = sys.exc_value
self._g_mutex.unlock()
## @brief Return the global shared variable with the methods' last return value
@ -100,3 +119,7 @@ class ScriptAdapter :
def mutex_test_lock(self):
return self._g_mutex.test()
def get_last_exception(self):
return self._g_last_exception