3 //=============================================================================
5 * @file Message_Queue_Vx.h
7 * @author Douglas C. Schmidt <d.schmidt@vanderbilt.edu>
9 //=============================================================================
11 #ifndef ACE_MESSAGE_QUEUE_VX_H
12 #define ACE_MESSAGE_QUEUE_VX_H
13 #include /**/ "ace/pre.h"
15 #include "ace/Message_Block.h"
17 #if !defined (ACE_LACKS_PRAGMA_ONCE)
19 #endif /* ACE_LACKS_PRAGMA_ONCE */
21 #if defined (ACE_VXWORKS)
23 // Include the templates here.
24 #include "ace/Message_Queue_T.h"
26 # include /**/ <msgQLib.h>
27 # include "ace/Null_Mutex.h"
28 # include "ace/Null_Condition.h"
30 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
33 * @class ACE_Message_Queue_Vx
35 * @brief Wrapper for VxWorks message queues.
37 * Specialization of ACE_Message_Queue to simply wrap VxWorks
38 * MsgQ. It does not use any synchronization, because it relies
39 * on the native MsgQ implementation to take care of that. The
40 * only system calls that it uses are VxWorks msgQLib calls, so
41 * it is suitable for use in interrupt service routines.
42 * @note *Many* ACE_Message_Queue features are not supported with
43 * this specialization, including:
44 * * The two size arguments to the constructor and <open> are
45 * interpreted differently. The first is interpreted as the
46 * maximum number of bytes in a message. The second is
47 * interpreted as the maximum number of messages that can be
49 * * <dequeue_head> *requires* that the ACE_Message_Block
50 * pointer argument point to an ACE_Message_Block that was
51 * allocated by the caller. It must be big enough to support
52 * the received message, without using continuation. The
53 * pointer argument is not modified.
54 * * Message priority. MSG_Q_FIFO is hard-coded.
55 * * enqueue method timeouts.
56 * * <peek_dequeue_head>.
57 * * <ACE_Message_Queue_Iterators>.
58 * * The ability to change low and high water marks after creation.
59 * * Message_Block chains. The continuation field of ACE_Message_Block
60 * * is ignored; only the first block of a fragment chain is
63 class ACE_Export ACE_Message_Queue_Vx
: public ACE_Message_Queue
<ACE_NULL_SYNCH
>
66 ACE_Message_Queue_Vx (size_t max_messages
,
67 size_t max_message_length
,
68 ACE_Notification_Strategy
* = 0);
70 // Create a message queue with all the defaults.
71 /// Create a message queue with all the defaults.
72 virtual int open (size_t max_messages
,
73 size_t max_message_length
,
74 ACE_Notification_Strategy
* = 0);
76 /// Close down the message queue and release all resources.
79 /// Close down the message queue and release all resources.
80 virtual ~ACE_Message_Queue_Vx ();
82 // = Queue statistic methods.
84 * Number of total bytes on the queue, i.e., sum of the message
87 virtual size_t message_bytes ();
90 * Number of total length on the queue, i.e., sum of the message
93 virtual size_t message_length ();
96 * Number of total messages on the queue.
98 virtual size_t message_count ();
100 // = Manual changes to these stats (used when queued message blocks
101 // change size or lengths).
103 * New value of the number of total bytes on the queue, i.e., sum of
104 * the message block sizes.
106 virtual void message_bytes (size_t new_size
);
109 * New value of the number of total length on the queue, i.e., sum
110 * of the message block lengths.
112 virtual void message_length (size_t new_length
);
114 // = Flow control routines
116 /// Get high watermark.
117 virtual size_t high_water_mark ();
119 /// Set high watermark.
120 virtual void high_water_mark (size_t hwm
);
122 /// Get low watermark.
123 virtual size_t low_water_mark ();
125 /// Set low watermark.
126 virtual void low_water_mark (size_t lwm
);
128 // = Activation control methods.
130 /// Dump the state of an object.
133 /// Declare the dynamic allocation hooks.
134 ACE_ALLOC_HOOK_DECLARE
;
137 /// Enqueue an ACE_Message_Block * in accordance with its priority.
138 virtual int enqueue_i (ACE_Message_Block
*new_item
);
140 /// Enqueue an ACE_Message_Block * in accordance with its deadline time.
141 virtual int enqueue_deadline_i (ACE_Message_Block
*new_item
);
143 /// Enqueue an <ACE_Message_Block *> at the end of the queue.
144 virtual int enqueue_tail_i (ACE_Message_Block
*new_item
);
146 /// Enqueue an <ACE_Message_Block *> at the head of the queue.
147 virtual int enqueue_head_i (ACE_Message_Block
*new_item
);
149 /// Dequeue and return the <ACE_Message_Block *> at the head of the
151 virtual int dequeue_head_i (ACE_Message_Block
*&first_item
);
153 /// Dequeue and return the <ACE_Message_Block *> with the lowest
155 virtual int dequeue_prio_i (ACE_Message_Block
*&dequeued
);
157 /// Dequeue and return the <ACE_Message_Block *> at the tail of the
159 virtual int dequeue_tail_i (ACE_Message_Block
*&dequeued
);
161 /// Dequeue and return the <ACE_Message_Block *> that has the lowest
163 virtual int dequeue_deadline_i (ACE_Message_Block
*&dequeued
);
165 // = Check the boundary conditions (assumes locks are held).
166 /// True if queue is full, else false.
167 virtual bool is_full_i ();
169 /// True if queue is empty, else false.
170 virtual bool is_empty_i ();
172 // = Implementation of public <activate>/<deactivate> methods above.
174 // These methods assume locks are held.
176 // = Helper methods to factor out common #ifdef code.
177 /// Wait for the queue to become non-full.
178 virtual int wait_not_full_cond (ACE_Time_Value
*tv
);
180 /// Wait for the queue to become non-empty.
181 virtual int wait_not_empty_cond (ACE_Time_Value
*tv
);
183 /// Inform any threads waiting to enqueue that they can procede.
184 virtual int signal_enqueue_waiters ();
186 /// Inform any threads waiting to dequeue that they can procede.
187 virtual int signal_dequeue_waiters ();
189 /// Access the underlying msgQ.
193 ACE_Message_Queue_Vx (const ACE_Message_Queue_Vx
&) = delete;
194 void operator= (const ACE_Message_Queue_Vx
&) = delete;
195 ACE_Message_Queue_Vx (ACE_Message_Queue_Vx
&&) = delete;
196 void operator= (ACE_Message_Queue_Vx
&&) = delete;
198 virtual int peek_dequeue_head (ACE_Message_Block
*&first_item
,
199 ACE_Time_Value
*tv
= 0);
202 /// Maximum number of messages that can be queued.
205 /// Maximum message size, in bytes.
206 int max_message_length_
;
209 ACE_END_VERSIONED_NAMESPACE_DECL
211 #endif /* ACE_VXWORKS */
213 #if defined (__ACE_INLINE__)
214 #include "ace/Message_Queue_Vx.inl"
215 #endif /* __ACE_INLINE__ */
217 #include /**/ "ace/post.h"
218 #endif /* ACE_MESSAGE_QUEUE_VX_H */