bool HTTPSourceMMIExtensionEventHandler::HTTPMMIEventQManager<T>::Peek
(
 T& eventToRead
)
{
  bool bOk = false;

  //Check if the queue is already empty, if not get the event from
  //the queue
  if (IsQEmpty())
  {
    QTV_MSG_PRIO( QTVDIAG_STREAMING, QTVDIAG_PRIO_MEDIUM,
                  "MMIEventQManager - MMI event queue empty" );
  }
  else
  {
    (void)MM_CriticalSection_Enter(m_hEventQLock);
    if (m_nEventReadIndex < ARR_SIZE(m_eventQ))
    {
      bOk = true;
      eventToRead = m_eventQ[m_nEventReadIndex];

      QTV_MSG_PRIO2( QTVDIAG_STREAMING, QTVDIAG_PRIO_MEDIUM,
                     "MMIEventQManager - Peeked event from index %u, "
                     "%u events remain", m_nEventReadIndex, m_nOutstandingEvents );
    }
    (void)MM_CriticalSection_Leave(m_hEventQLock);
  }

  return bOk;
}
Exemple #2
0
//++dralee_20060327
//only for PPS enabled. when sleepperiod command is set and no queued packets & pending Q
UCHAR CheckLastPacketIndication(IN PMRVDRV_ADAPTER Adapter)
{   
  
   if( Adapter->sleepperiod != 0 &&
       Adapter->TxPacketCount == 0 &&
       Adapter->CurCmd == 0 &&        //dralee_20060706
       IsQEmpty(&Adapter->CmdPendQ) )
       return 1;
   else 
       return 0;

}
int IsGraphBipartite(void)
{

    /* Start with node 0 of the graph as root node of BFS Tree */
    if (num >0) {
        /* Colour the first node or 0th node and EnQ it */
        color[0] = RED;
        EnQ(0);
    }

    while (!IsQEmpty()) {

        int k;
        /* DeQ one element and make it currently working Node */
        int cwn = DeQ();
        printf("Dequeued value is [%d] color[%d]\n", cwn, color[cwn]);
        if (IsQEmpty()) {
            printf(" Q is empty...\n");
        }


        /* Check each neighbouring node of currently working node and try color it opposite to currently working node*/
        for(k=0; k <num; k++) {
            if (mat[cwn][k]) {
                if (color[k] == color[cwn]) {
                    printf("Got an vertex [%d] from [%d] which is already coloured [%s]\n", k, cwn, whichcolor(color[k])); 
                    printf("Currently working node colour is also [%s]\n", whichcolor(color[cwn]));
                    return 0;
                } else  if (color[k] == NOTCOLORED) {
                    /* Color the adjacent node and Enqueue it */
                    color[k] = opposite(color[cwn]);
                    /* EnQ all the neightbouring nodes to Q */
                    EnQ(k);
                }
            }
        }

    }
    return 1;
}
int DeQ()
{
    if(IsQEmpty()) {
        return -1;
    }

    /* DeQueue element */
    int element = Q[f];

    if (f==r){ /* Only one element in Q */
        f = r = -1;
    } else {
        f++;
    }
    return element;
}
bool HTTPSourceMMIExtensionEventHandler::HTTPMMIEventQManager<T>::Dequeue
(
 T& eventToRead
)
{
  bool bOk = false;

  //Check if the queue is already empty, if not get the event from
  //the queue
  if (IsQEmpty())
  {
    QTV_MSG_PRIO( QTVDIAG_STREAMING, QTVDIAG_PRIO_MEDIUM,
                  "MMIEventQManager - MMI event queue empty" );
  }
  else
  {
    (void)MM_CriticalSection_Enter(m_hEventQLock);
    if (m_nEventReadIndex < ARR_SIZE(m_eventQ))
    {
      //Dequeue the event and update the read index and number of queued events
      bOk = true;
      eventToRead = m_eventQ[m_nEventReadIndex];
      m_nOutstandingEvents--;
      QTV_MSG_PRIO2( QTVDIAG_STREAMING, QTVDIAG_PRIO_MEDIUM,
                     "MMIEventQManager - Dequeued event from index %u, "
                     "%u events remain", m_nEventReadIndex, m_nOutstandingEvents );
      m_nEventReadIndex = (m_nEventReadIndex + 1) % (uint32)ARR_SIZE(m_eventQ);
    }
    else
    {
      QTV_MSG_PRIO1( QTVDIAG_STREAMING, QTVDIAG_PRIO_ERROR,
                     "MMIEventQManager - Invalid MMI event queue read index %u",
                     m_nEventReadIndex );
    }
    (void)MM_CriticalSection_Leave(m_hEventQLock);
  }
  return bOk;
}