Example #1
0
void _PyXBMC_ClearPendingCalls(PyThreadState* state)
{
  CSingleLock lock(g_critSectionPyCall);
  for(CallQueue::iterator it = g_callQueue.begin(); it!= g_callQueue.end();)
  {
    if(it->state == state)
      it = g_callQueue.erase(it);
    else
      it++;
  }
}
Example #2
0
void _PyXBMC_AddPendingCall(PyThreadState* state, int(*func)(void*), void *arg)
{
  CSingleLock lock(g_critSectionPyCall);
  SPending p;
  p.func  = func;
  p.args  = arg;
  p.state = state;
  g_callQueue.push_back(p);
}
Example #3
0
void _Py_MakePendingCalls()
{
    g_critSectionPyCall.enterMutex();

    CallQueue::iterator iter = g_callQueue.begin();
    while (iter != g_callQueue.end())
    {
        int(*f)(void*) = (*iter).first;
        void* arg = (*iter).second;
        g_callQueue.erase(iter);
        g_critSectionPyCall.leaveMutex();
        if (f)
            f(arg);
        //(*((*iter).first))((*iter).second);
        g_critSectionPyCall.enterMutex();
        iter = g_callQueue.begin();
    }
    g_critSectionPyCall.leaveMutex();
}
void _PyXBMC_MakePendingCalls()
{
  CSingleLock lock(g_critSectionPyCall);
  CallQueue::iterator iter = g_callQueue.begin();
  while (iter != g_callQueue.end())
  {
    SPending p(*iter);
    // only call when we are in the right thread state
    if(p.state != PyThreadState_Get())
    {
      iter++;
      continue;
    }
    g_callQueue.erase(iter);
    lock.Leave();
    if (p.func)
      p.func(p.args);
    //(*((*iter).first))((*iter).second);
    lock.Enter();
    iter = g_callQueue.begin();
  }
}
Example #5
0
void _PyXBMC_MakePendingCalls()
{
  CSingleLock lock(g_critSectionPyCall);
  CallQueue::iterator iter = g_callQueue.begin();
  while (iter != g_callQueue.end())
  {
    SPending p(*iter);
    // only call when we are in the right thread state
    if(p.state != PyThreadState_Get())
    {
      iter++;
      continue;
    }
    g_callQueue.erase(iter);
    lock.Leave();
    if (p.func)
    {
      p.func(p.args);

      // Since the callback is likely to make it into python, and since
      // not all of the callback functions handle errors, the error state
      // may remain set from the previous call. As a result subsequent calls
      // to callback functions exhibit odd behavior difficult to debug.
      if (PyErr_Occurred())
      {
        CLog::Log(LOGERROR,"Exception in python script callback execution");

        // This clears the python error state and prints it to the log
        PyErr_Print();
      }

    }
    //(*((*iter).first))((*iter).second);
    lock.Enter();
    iter = g_callQueue.begin();
  }
}
Example #6
0
void _Py_AddPendingCall(int(*func)(void*), void *arg)
{
    g_critSectionPyCall.enterMutex();
    g_callQueue.push_back(Func(func, arg));
    g_critSectionPyCall.leaveMutex();
}