本文整理汇总了C++中ACE_Unbounded_Queue::is_empty方法的典型用法代码示例。如果您正苦于以下问题:C++ ACE_Unbounded_Queue::is_empty方法的具体用法?C++ ACE_Unbounded_Queue::is_empty怎么用?C++ ACE_Unbounded_Queue::is_empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ACE_Unbounded_Queue
的用法示例。
在下文中一共展示了ACE_Unbounded_Queue::is_empty方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: remove_from_owner
void Gadget_Part_Impl::remove_from_owner (void)
{
// Need to guarantee the existence of the owner for the duration of this call.
Gadget_var owner = owner_;
// Weak pointers are automatically set to NULL if the object they refer to
// is deleted. We can use this fact to check that our owner still exists.
if (owner == 0)
return;
// Take all existing parts from the owner and build up a temporary list. If
// we find ourselves then we won't add ourselves to the list.
ACE_Unbounded_Queue<Gadget_Part_var> parts;
for (;;)
{
Gadget_Part_var part = owner->remove_part ();
if (part == 0)
break;
if (part != this)
parts.enqueue_tail (part);
}
// Add the remaining parts back to the gadget.
while (!parts.is_empty ())
{
Gadget_Part_var part;
parts.dequeue_head (part);
owner->add_part (part);
}
}
示例2: saveFile
bool saveFile(const char *name) {
mutex.wait();
saving = false;
Sound total;
total.resize(samples,channels);
long int at = 0;
while (!sounds.is_empty()) {
Sound tmp;
sounds.dequeue_head(tmp);
for (int i=0; i<channels; i++) {
for (int j=0; j<tmp.getSamples(); j++) {
total.set(tmp.get(j,i),at+j,i);
}
}
total.setFrequency(tmp.getFrequency());
at += tmp.getSamples();
}
mutex.post();
bool ok = write(total,name);
if (ok) {
printf("Wrote audio to %s\n", name);
}
samples = 0;
channels = 0;
return ok;
}
示例3: return
// Listing 3
// Listing 5 code/ch16
int
LF_ThreadPool::elect_new_leader (void)
{
ACE_TRACE (ACE_TEXT ("LF_ThreadPool::elect_new_leader"));
ACE_GUARD_RETURN
(ACE_Thread_Mutex, leader_mon, this->leader_lock_, -1);
leader_active (0);
// Wake up a follower
if (!followers_.is_empty ())
{
ACE_GUARD_RETURN (ACE_Thread_Mutex,
follower_mon,
this->followers_lock_,
-1);
// Get the old follower.
Follower *fw;
if (this->followers_.dequeue_head (fw) != 0)
return -1;
ACE_DEBUG ((LM_ERROR,
ACE_TEXT ("(%t) Resigning and Electing %d\n"),
fw->owner ()));
return (fw->signal () == 0) ? 0 : -1;
}
else
{
ACE_DEBUG
((LM_ERROR, ACE_TEXT ("(%t) Oops no followers left\n")));
return -1;
}
}
示例4: while
void
be_visitor_typecode_defn::
queue_reset (ACE_Unbounded_Queue <be_visitor_typecode_defn::QNode *> & queue)
{
while (!queue.is_empty ())
{
be_visitor_typecode_defn::QNode * qnode = 0;
(void) queue.dequeue_head (qnode);
delete qnode;
}
}
示例5: 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 ());
}
示例6: recv
void Socket_Impl::recv (Message_ptr m)
{
if (m->find (Data::id) != 0 || m->find (NoData::id) != 0)
{
if (!loop_)
{
Address to (static_cast<To const*> (m->find (To::id))->address ());
Address from (
static_cast<From const*> (m->find (From::id))->address ());
if (to == from)
return;
}
Lock l (mutex_);
//if (queue_.size () != 0)
// cerr << "recv socket queue size: " << queue_.size () << endl;
//FUZZ: disable check_for_lack_ACE_OS
bool signal (queue_.is_empty ());
//FUZZ: enable check_for_lack_ACE_OS
queue_.enqueue_tail (m);
if (signal)
{
// Also write to the pipe.
if (signal_pipe_.write_handle () != ACE_INVALID_HANDLE)
{
char c;
if (signal_pipe_.send (&c, 1) != 1)
{
// perror ("write: ");
ACE_OS::abort ();
}
}
cond_.signal ();
}
}
}