Exemple #1
0
TEST(SharedMessageQueue, Basic)
{
  SharedMessageQueue q;
  ASSERT_TRUE(q.WaitEmpty(0));
  q.Enqueue(new DynamicInteger(10));
  ASSERT_FALSE(q.WaitEmpty(1));
  q.Enqueue(new DynamicInteger(20));
  q.Enqueue(new DynamicInteger(30));
  q.Enqueue(new DynamicInteger(40));

  std::auto_ptr<DynamicInteger> i;
  i.reset(dynamic_cast<DynamicInteger*>(q.Dequeue(1))); ASSERT_EQ(10, i->GetValue());
  i.reset(dynamic_cast<DynamicInteger*>(q.Dequeue(1))); ASSERT_EQ(20, i->GetValue());
  i.reset(dynamic_cast<DynamicInteger*>(q.Dequeue(1))); ASSERT_EQ(30, i->GetValue());
  ASSERT_FALSE(q.WaitEmpty(1));
  i.reset(dynamic_cast<DynamicInteger*>(q.Dequeue(1))); ASSERT_EQ(40, i->GetValue());
  ASSERT_TRUE(q.WaitEmpty(0));
  ASSERT_EQ(NULL, q.Dequeue(1));
}
Exemple #2
0
TEST(SharedMessageQueue, Clean)
{
  try
  {
    SharedMessageQueue q;
    q.Enqueue(new DynamicInteger(10));
    q.Enqueue(new DynamicInteger(20));  
    throw OrthancException("Nope");
  }
  catch (OrthancException)
  {
  }
}
Exemple #3
0
  size_t ServerJob::Submit(SharedMessageQueue& target,
                           ServerCommandInstance::IListener& listener)
  {
    if (submitted_)
    {
      // This job has already been submitted
      throw OrthancException(ErrorCode_BadSequenceOfCalls);
    }

    CheckOrdering();

    size_t size = filters_.size();

    for (std::list<ServerCommandInstance*>::iterator 
           it = filters_.begin(); it != filters_.end(); ++it)
    {
      target.Enqueue(*it);
    }

    filters_.clear();
    submitted_ = true;

    return size;
  }