summaryrefslogtreecommitdiff
path: root/ace/Activation_Queue.h
blob: c7ca55f6a26351dfae591be0fc81835027deed38 (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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/* -*- C++ -*- */
// $Id$

// ============================================================================
//
// = LIBRARY
//    ace
//
// = FILENAME
//    Activation_Queue.h
//
// = AUTHOR
//    Andres Kruse <Andres.Kruse@cern.ch> and Douglas C. Schmidt
//    <schmidt@cs.wustl.edu>
//
// ============================================================================

#ifndef ACE_ACTIVATION_QUEUE_H
#define ACE_ACTIVATION_QUEUE_H

#include "ace/Synch_T.h"

#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */

#include "ace/Message_Queue.h"
#include "ace/Method_Request.h"

// Be compatible with the terminology in the POSA2 book!
#define ACE_Activation_List ACE_Activation_Queue 

class ACE_Export ACE_Activation_Queue
{
  // = TITLE
  //     Reifies a method into a request.  Subclasses typically
  //     represent necessary state and behavior.
  //
  // = DESCRIPTION
  //     A <Method_Request> is inserted in the <Activation_Queue>,
  //     where it is subsequently removed by the <Scheduler>, which
  //     invokes its <call> method..
public:
  // = Initialization and termination methods.
  ACE_Activation_Queue (ACE_Message_Queue<ACE_SYNCH> *new_queue = 0);
  // Constructor.

  virtual ~ACE_Activation_Queue (void);
  // Destructor.

  // = Activate Queue operations.

  // For the following two methods if <timeout> == 0, the caller will
  // block until action is possible, else will wait until the absolute
  // time specified in *<timeout> elapses.  These calls will return,
  // however, when queue is closed, deactivated, when a signal occurs,
  // or if the time specified in timeout elapses, (in which case errno
  // = EWOULDBLOCK).

  ACE_Method_Request *dequeue (ACE_Time_Value *tv = 0);
  // Dequeue the next available <Method_Request>.

  int enqueue (ACE_Method_Request *new_method_request,
               ACE_Time_Value *tv = 0);
  // Enqueue the <Method_Request> in priority order.  The priority is
  // determined by the <priority> method of the <new_message_request>.

  int method_count (void) const;
  // Get the current number of method objects in the queue.

  int is_empty (void) const;
  // Returns 1 if the queue is empty, 0 otherwise.

  int is_full (void) const;
  // Returns 1 if the queue is full, 0 otherwise.

  void dump (void) const;
  // Dump the state of an request.

  ACE_ALLOC_HOOK_DECLARE;
  // Declare the dynamic allocation hooks.

protected:
  ACE_Message_Queue<ACE_SYNCH> *queue_;
  // Stores the <Method_Requests>.

  int delete_queue_;
  // Keeps track of whether we need to delete the queue.
};

#if defined (__ACE_INLINE__)
#include "ace/Activation_Queue.i"
#endif /* __ACE_INLINE__ */

#endif /* ACE_ACTIVATION_QUEUE_H */