summaryrefslogtreecommitdiff
path: root/ace/Activation_Queue.cpp
blob: e536bfb030f678719797bd60489de63950fa73b5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// Activation_Queue.cpp
// $Id$

#define ACE_BUILD_DLL

#include "ace/Activation_Queue.h"

// Dump the state of an object.

void 
ACE_Activation_Queue::dump (void) const
{
  ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
  ACE_DEBUG ((LM_DEBUG,
	      "delete_queue_ = %d\n",
	      this->delete_queue_));
  ACE_DEBUG ((LM_INFO,"queue_: \n"));
  if (this->queue_)
    this->queue_->dump();
  else
    ACE_DEBUG ((LM_DEBUG,"(NULL)\n"));
  ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
}

ACE_Activation_Queue::ACE_Activation_Queue (ACE_Message_Queue<ACE_SYNCH> *new_queue) 
  : delete_queue_ (0)
{
  if (new_queue)
    this->queue_ = new_queue;
  else
    {
      ACE_NEW (this->queue_, ACE_Message_Queue<ACE_SYNCH>);
      this->delete_queue_ = 1;
    }
}

ACE_Activation_Queue::~ACE_Activation_Queue (void) 
{
  if (this->delete_queue_ != 0)
    delete this->queue_;
}

ACE_Method_Object *
ACE_Activation_Queue::dequeue (ACE_Time_Value *tv)
{
  ACE_Message_Block *mb;
  ACE_Method_Object *mo;

  // Dequeue the message.
  this->queue_->dequeue_head (mb, tv);

  // Get the method object.
  mo = (ACE_Method_Object *) mb->base ();

  // Delete the message block.
  delete mb;
  return mo;
}

int 
ACE_Activation_Queue::enqueue (ACE_Method_Object *mo,
			       ACE_Time_Value *tv)
{
  ACE_Message_Block *mb;

  ACE_NEW_RETURN (mb, ACE_Message_Block ((char *) mo), -1);

  return this->queue_->enqueue (mb, tv);
}