20 #ifndef __CVC4__CHANNEL_H
21 #define __CVC4__CHANNEL_H
23 #include <boost/circular_buffer.hpp>
24 #include <boost/thread/mutex.hpp>
25 #include <boost/thread/condition.hpp>
26 #include <boost/thread/thread.hpp>
27 #include <boost/call_traits.hpp>
28 #include <boost/progress.hpp>
29 #include <boost/bind.hpp>
43 virtual bool push(
const T&) = 0;
49 virtual bool empty() = 0;
52 virtual bool full() = 0;
66 typedef typename container_type::size_type
size_type;
68 typedef typename boost::call_traits<value_type>::param_type
param_type;
72 bool push(param_type item){
75 boost::mutex::scoped_lock lock(m_mutex);
77 m_container.push_front(item);
80 m_not_empty.notify_one();
86 boost::mutex::scoped_lock lock(m_mutex);
88 ret = m_container[--m_unread];
90 m_not_full.notify_one();
95 bool empty() {
return not is_not_empty(); }
96 bool full() {
return not is_not_full(); }
102 bool is_not_empty()
const {
return m_unread > 0; }
103 bool is_not_full()
const {
return m_unread < m_container.capacity(); }
106 container_type m_container;
107 boost::mutex m_mutex;
108 boost::condition m_not_empty;
109 boost::condition m_not_full;
boost::circular_buffer< T > container_type
SynchronizedSharedChannel(size_type capacity)
bool push(param_type item)
Macros that should be defined everywhere during the building of the libraries and driver binary...
SharedChannel(int maxsize)
container_type::value_type value_type
container_type::size_type size_type
boost::call_traits< value_type >::param_type param_type