- Added Policy::wants() and updated related code. Scheduler::get_ready_queue() still always returns a process queue...

git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@615 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
elvez 2006-06-09 16:51:53 +00:00
parent e5b90a39ad
commit 1e75fe91f1
9 changed files with 81 additions and 4 deletions

View file

@ -138,7 +138,8 @@ PythonPolicy::is_pre_emptive() const throw(UserInterruptException)
int
PythonPolicy::get_time_slice() const throw(UserInterruptException) {
PythonPolicy::get_time_slice() const throw(UserInterruptException)
{
PyObject* retval = PyObject_CallMethod(_adapter, "async_get_time_slice", NULL);
Py_DECREF(retval);
@ -153,6 +154,27 @@ PythonPolicy::get_time_slice() const throw(UserInterruptException) {
return tmp < 0 ? numeric_limits<int>::max() : static_cast<int>(tmp);
}
policy_sorts_type
PythonPolicy::wants() const throw(UserInterruptException)
{
PyObject* retval = PyObject_CallMethod(_adapter, "async_wants", NULL);
Py_DECREF(retval);
wait_unlock();
// Parse return value stored in global Python object
retval = PyObject_CallMethod(_adapter, "get_return_value", NULL);
assert(retval);
long tmp = PyInt_AsLong(retval);
Py_DECREF(retval);
//FIXME add the MalformedPolicyException class and throw it the else
// branch instead
if(tmp == policy_sorts_threads || tmp == policy_sorts_processes)
return static_cast<policy_sorts_type>(tmp);
else
return policy_sorts_processes;
}
void
PythonPolicy::wait_unlock() const throw(UserInterruptException)