本文整理汇总了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;
}
示例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);
}
示例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);
}