本文整理汇总了C++中ACE_Unbounded_Queue::enqueue_head方法的典型用法代码示例。如果您正苦于以下问题:C++ ACE_Unbounded_Queue::enqueue_head方法的具体用法?C++ ACE_Unbounded_Queue::enqueue_head怎么用?C++ ACE_Unbounded_Queue::enqueue_head使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ACE_Unbounded_Queue
的用法示例。
在下文中一共展示了ACE_Unbounded_Queue::enqueue_head方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: runStackUnboundedQueue
// Listing 1 code/ch05
int QueueExample::runStackUnboundedQueue (void)
{
ACE_TRACE ("QueueExample::runStackUnboundedQueue");
ACE_Unbounded_Queue<DataElement> queue;
DataElement elem1[10];
int i;
for (i = 0; i < 10; i++)
{
elem1[i].setData (9-i);
queue.enqueue_head (elem1[i]);
}
DataElement elem2[10];
for (i = 0; i < 10; i++)
{
elem2[i].setData (i+10);
queue.enqueue_tail (elem2[i]);
}
for (ACE_Unbounded_Queue_Iterator<DataElement> iter (queue);
!iter.done ();
iter.advance ())
{
DataElement *elem = 0;
iter.next (elem);
ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("%d:"), elem->getData ()));
}
return 0;
}
示例2: runHeapUnboundedQueue
// Listing 1
// Listing 2 code/ch05
int QueueExample::runHeapUnboundedQueue (void)
{
ACE_TRACE ("QueueExample::runHeapUnboundedQueue");
ACE_Unbounded_Queue<DataElement*> queue;
for (int i = 0; i < 20; i++)
{
DataElement *elem;
ACE_NEW_RETURN(elem, DataElement (i), -1);
queue.enqueue_head (elem);
}
for (ACE_Unbounded_Queue_Iterator<DataElement*> iter
= queue.begin ();
!iter.done ();
iter.advance ())
{
DataElement **elem = 0;
iter.next(elem);
ACE_DEBUG
((LM_DEBUG, ACE_TEXT ("%d:"), (*elem)->getData ()));
delete (*elem);
}
return 0;
}
示例3: l
ssize_t Socket_Impl::
size_ (ACE_Time_Value const* timeout)
{
ACE_Time_Value abs_time;
if (timeout)
abs_time = ACE_OS::gettimeofday () + *timeout;
Lock l (mutex_);
while (queue_.is_empty ())
{
if (timeout)
{
if (cond_.wait (&abs_time) != -1)
break;
}
else
{
if (cond_.wait () != -1)
break;
}
return -1; // errno is already set
}
// I can't get the head of the queue without actually dequeuing
// the element.
//
Message_ptr m;
if (queue_.dequeue_head (m) == -1)
ACE_OS::abort ();
if (queue_.enqueue_head (m) == -1)
ACE_OS::abort ();
if (m->find (NoData::id) != 0)
{
errno = ENOENT;
return -1;
}
Data const* d = static_cast<Data const*>(m->find (Data::id));
return static_cast<ssize_t> (d->size ());
}