1 // author : Boris Kolpackov <boris@dre.vanderbilt.edu>
3 #ifndef TMCAST_MT_QUEUE_HPP
4 #define TMCAST_MT_QUEUE_HPP
6 #include "ace/Unbounded_Set.h"
7 #include "ace/Unbounded_Queue.h"
8 #include "ace/os_include/sys/os_types.h"
9 #include "ace/Condition_T.h"
17 typename Q
= ACE_Unbounded_Queue
<T
> >
21 typedef T ElementType
;
23 typedef C ConditionalType
;
29 : mutexp_ (new MutexType
),
36 MTQueue (MutexType
& mutex
)
48 return queue_
.is_empty ();
54 return queue_
.size ();
57 // typedef typename QueueType::Empty Empty;
64 ACE_Unbounded_Queue_Iterator
<T
> f (queue_
);
66 if (!f
.next (tmp
)) throw Empty ();
75 ACE_Unbounded_Queue_Const_Iterator
<T
> f (queue_
);
77 if (!f
.next (tmp
)) throw Empty ();
86 return queue_.back ();
93 return queue_.back ();
101 queue_
.enqueue_tail (t
);
108 queue_
.dequeue_head (junk
);
125 for (ConditionalSetConstIterator_
i (cond_set_
);
129 ConditionalType
** c
= 0;
141 subscribe (ConditionalType
& c
)
143 //@@ should check for duplicates
145 cond_set_
.insert (&c
);
149 unsubscribe (ConditionalType
& c
)
151 //@@ should check for absence
153 cond_set_
.remove (&c
);
157 std::unique_ptr
<MutexType
> mutexp_
;
162 ACE_Unbounded_Set
<ConditionalType
*>
166 ACE_Unbounded_Set_Const_Iterator
<ConditionalType
*>
167 ConditionalSetConstIterator_
;
169 ConditionalSet_ cond_set_
;
171 mutable bool signal_
;
175 #endif // TMCAST_MT_QUEUE_HPP