当前位置: 首页>>代码示例>>C++>>正文


C++ MessageQueue::dequeue方法代码示例

本文整理汇总了C++中MessageQueue::dequeue方法的典型用法代码示例。如果您正苦于以下问题:C++ MessageQueue::dequeue方法的具体用法?C++ MessageQueue::dequeue怎么用?C++ MessageQueue::dequeue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MessageQueue的用法示例。


在下文中一共展示了MessageQueue::dequeue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: deq

PEGASUS_THREAD_RETURN PEGASUS_THREAD_CDECL deq(void * parm)
{
    Thread* my_thread = (Thread *)parm;
  
    parmdef * Parm = (parmdef *)my_thread->get_parm();
    Uint32 type, key;

    int first = Parm->first;
    int second = Parm->second;
    int count = Parm->count;
    Condition * condstart = Parm->cond_start;
    MessageQueue * mq = Parm->mq;
    
    condstart->signal(my_thread->self());

    Message * message;
    type = 0;
    key = 0;

    while (type != MY_CANCEL_TYPE)
    {
        message = mq->dequeue();
        while (!message) {
#if defined PEGASUS_OS_SOLARIS && defined SUNOS_5_6
	    pegasus_sleep(1);
#endif
            message = mq->dequeue();
        }

        key = message->getKey();
        type = message->getType();
        delete message;
        if (type == 19)
            assert(key == 10946);
    }

    if (verbose)
#if defined (PEGASUS_OS_VMS)
      // 
      // pegasus_thread_self returns long-long-unsigned.
      // 
      printf("Received Cancel Message, %llu about to end\n", pegasus_thread_self());
#else
        cout << "Received Cancel Message, " << pegasus_thread_self() <<
            " about to end\n";
#endif
    my_thread->exit_self(0);
    return NULL;
}
开发者ID:ncultra,项目名称:Pegasus-2.5,代码行数:49,代码来源:IPC.cpp

示例2: deq

ThreadReturnType PEGASUS_THREAD_CDECL deq(void * parm)
{
    Thread* my_thread = (Thread *)parm;

    parmdef * Parm = (parmdef *)my_thread->get_parm();
    MessageType type;

    int first = Parm->first;
    int second = Parm->second;
    int count = Parm->count;
    Condition * condstart = Parm->cond_start;
    MessageQueue * mq = Parm->mq;

    condstart->signal();

    Message * message;
    type = 0;

    while (type != CLOSE_CONNECTION_MESSAGE)
    {
        message = mq->dequeue();
        while (!message)
        {
            message = mq->dequeue();
        }

        type = message->getType();
        delete message;
    }

    if (verbose)
    {
#if defined (PEGASUS_OS_VMS)
        //
        // Threads::self returns long-long-unsigned.
        //
        printf("Received Cancel Message, %llu about to end\n", Threads::self());
#else
        cout << "Received Cancel Message, " << Threads::self() <<
            " about to end\n";
#endif
    }

    return ThreadReturnType(0);
}
开发者ID:brunolauze,项目名称:pegasus,代码行数:45,代码来源:IPC.cpp

示例3: TestMessageQueue1

void TestMessageQueue1()
{
    MessageQueue q;

    Uint32 sum = 0;

    for (Uint32 i = 1; i <= 5; i++)
    {
	q.enqueue(new Alarm(i));
	sum += i;
    }

    assert(Sum(q) == sum);

    // Test removing from the middle:
    Message* m = q.findByKey(3);
    assert(m != 0);
    q.remove(m);
    assert(Sum(q) == sum - 3);
    assert(q.getCount() == 4);

    // Test removing from the front:
    q.remove(q.front());
    assert(Sum(q) == sum - 3 - 1);
    assert(q.getCount() == 3);

    // Test removing from the front:
    q.remove(q.back());
    assert(Sum(q) == sum - 3 - 1 - 5);
    assert(q.getCount() == 2);

    // Test dequeue:
    m = q.dequeue();
    assert(m->getKey() == 2);
    assert(Sum(q) == sum - 3 - 1 - 5 - 2);
    assert(q.getCount() == 1);

    // Test dequeue:
    m = q.dequeue();
    assert(m->getKey() == 4);
    assert(Sum(q) == sum - 3 - 1 - 5 - 2 - 4);
    assert(q.getCount() == 0);
}
开发者ID:ncultra,项目名称:Pegasus-2.5,代码行数:43,代码来源:MessageQueue.cpp


注:本文中的MessageQueue::dequeue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。