- Tadaaaan! Fixed it! Now:

- SWIG generate interface doesn't do a mess with namespaces anymore
  - Improved PythonPolicy to be acceptably faster
  - FCFS implemented, sir!
  - FIXME : the qsort implementation doesn't seem right


git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@413 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
tchernobog 2006-02-23 21:50:43 +00:00
parent 876fb85614
commit dfe1593b44
4 changed files with 53 additions and 31 deletions

View file

@ -162,18 +162,24 @@ void
PythonPolicy::wait_unlock() const throw(UserInterruptException)
{
PyThreadState *_save;
Py_UNBLOCK_THREADS
sleep(2); // hack'a'ton! magggggiccc nummmbeeerrrrrs!!
Py_BLOCK_THREADS
int i = 0; // We give the sort_queue() three seconds max time, then...
// we shot it stone dead! Bang.
// Now check if lock has been released, else
// throw an exception
PyObject* retval = PyObject_CallMethod(_lock, "test", NULL);
bool still_locked = static_cast<bool>(PyInt_AsLong(retval));
Py_DECREF(retval);
bool still_locked;
do {
Py_UNBLOCK_THREADS;
usleep(25000); // hack'a'ton! magggggiccc nummmbeeerrrrrs!!
Py_BLOCK_THREADS;
PyObject* retval = PyObject_CallMethod(_lock, "test", NULL);
still_locked = static_cast<bool>(PyInt_AsLong(retval));
Py_DECREF(retval);
if(i++ > 120)
throw UserInterruptException("User-defined policy is "
"taking too long to terminate.");
} while(still_locked);
if(still_locked)
throw UserInterruptException("User-defined policy is taking too long to terminate.");
// What we should really do here:
/* do {