- Audited some files

git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@1148 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
elvez 2006-09-14 15:10:48 +00:00
parent c78794e27d
commit 90c562006a
7 changed files with 106 additions and 43 deletions

View file

@ -1,3 +1,23 @@
# src/ScriptAdapter.py - Copyright 2005, 2006, University
# of Padova, dept. of Pure and Applied
# Mathematics
#
# This file is part of SGPEMv2.
#
# This is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# SGPEMv2 is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with SGPEMv2; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
import sys, mutex, thread
import sgpem
@ -14,7 +34,7 @@ import sgpem
# adapter = ScriptAdapter(UserPolicyClass)
# @endcode
#
# The user shouldn't care about this class at all.
# @remarks The user shouldn't care about this class at all.
class ScriptAdapter :
## @var The policy this ScriptAdapter will use for calls
_policy = None
@ -23,9 +43,11 @@ class ScriptAdapter :
# when a threaded function returns
_ret_val = None
## Var Testable syncronization object
## @var Testable syncronization object
_g_mutex = mutex.mutex()
## @var The exception raised from the last called user-defined
# method. It's value is \c None if no exception were raised
_g_last_exception = None
## @brief Constructor of ScriptAdapter
@ -75,6 +97,9 @@ class ScriptAdapter :
try:
self._policy.sort_queue(queue)
except:
# exception raised in user-defined method,
# save it so the C++ code can tell the
# user what went wrong
self._g_last_exception = sys.exc_value
self._g_mutex.unlock()
@ -93,6 +118,9 @@ class ScriptAdapter :
try:
self._ret_val = self._policy.is_preemptive()
except:
# exception raised in user-defined method,
# save it so the C++ code can tell the
# user what went wrong
self._g_last_exception = sys.exc_value
self._g_mutex.unlock()
@ -110,6 +138,9 @@ class ScriptAdapter :
try:
self._ret_val = self._policy.get_time_slice()
except:
# exception raised in user-defined method,
# save it so the C++ code can tell the
# user what went wrong
self._g_last_exception = sys.exc_value
self._g_mutex.unlock()