Beispiel #1
0
int main(int argc, char *argv[])
{
    void *p = NULL;
    long msg = 0;
    void *pMsg = NULL;

    p = QueueCreate(10);
    if (NULL == p)
    {
        printf("Create queue failed.\n");
        return -1;
    }

    msg = 90;
    while (msg--)
    {
        if (QueuePush(p, (void *)msg) < 0)
        {
            printf("----------Queue is full now-----------\n");
            break;
        }

        printf("Push ok. [msg: %ld, size: %d]\n", msg, QueueGetSize(p));
    }
    
    msg = 15;
    while (msg--)
    {
        if (QueuePopPush(p, (void *)msg, &pMsg) < 0)
        {
            printf("----------QueuePopPush failed-----------\n");
            break;
        }

        printf("PopPush ok. [msgPop: %ld, msgPush: %ld, size: %d]\n",
            (long)pMsg, msg, QueueGetSize(p));
    }
    
    msg = 60;
    while (msg--)
    {
        if (QueuePop(p, &pMsg) < 0)
        {
            printf("----------Queue is empty now-----------\n");
            break;
        }

        printf("Pop ok. [msg: %ld, size: %d]\n", (long)pMsg, QueueGetSize(p));
    }

    QueueDestroy(p);
    system("pause");

    return 0;
}
CTAsyncWorkQueue::~CTAsyncWorkQueue()
{
    int size = 0;

    m_stopped = 1;

    if ((NULL != m_pEndQ) && (NULL != m_pRunQ))
    {
        while (1)
        {
            size = QueueGetSize(m_pEndQ) + QueueGetSize(m_pRunQ);
            if (0 == size)
            {
                break;
            }

            printf("QueueGetSize(m_pEndQ): %d, QueueGetSize(m_pRunQ): %d\n",
                QueueGetSize(m_pEndQ), QueueGetSize(m_pRunQ));
            usleep(100 * 1000);
        }
    }

    if (NULL == m_pThreadsGroup)
    {
        ThreadsGroupDestroy(m_pThreadsGroup, 1, 0);
        m_pThreadsGroup = NULL;
    }

    if (NULL == m_pRunQ)
    {
        QueueDestroy(m_pRunQ);
        m_pRunQ = NULL;
    }

    if (NULL == m_pEndQ)
    {
        QueueDestroy(m_pEndQ);
        m_pEndQ = NULL;
    }
}
Beispiel #3
0
DWORD COMMAPI ComOutCount(HCOMM hc)
{
  /* Okay, we need to fake this too, so we'll just always
   * say the buffer is empty.
   */

  ComIsOnline(hc);
  return 0;

#if 0 /* not yet */
  return QueueGetSize(&hc->cqTx);
#endif
}
Beispiel #4
0
DWORD COMMAPI ComInCount(HCOMM hc)
{
  /* Okay, we need to fake this so that mdm_avail() will
   * work. Let's peek, if that works, return that there is
   * one byte available for read..
   */

  int ch;

  if (!ComIsOnline(hc))
    return 0;

  ch = ComPeek(hc);

  return (ch >= 0 ? 1 : 0);
#if 0
  return QueueGetSize(&hc->cqRx);
#endif
}