1#ifndef HAVE_TOM__SHARED_LIST_HPP
2#define HAVE_TOM__SHARED_LIST_HPP
4#include <tom-util/defines.hpp>
6#include <boost/thread/barrier.hpp>
7#include <boost/thread/thread.hpp>
8#include <boost/thread/condition.hpp>
9#include <boost/thread/xtime.hpp>
48 push_back(
const T & );
57 typedef boost::mutex::scoped_lock lock;
60 mutable boost::condition m_buffer_empty;
61 mutable boost::condition m_buffer_ready;
62 mutable boost::mutex m_monitor;
65 mutable std::list<T> m_list;
75 if ( ( ! m_read_only ) && m_list.empty() )
76 m_buffer_ready.wait(l);
78 if ( ! m_list.empty() )
85 shared_list<T>::pop_front( T &v )
90 if ( ( ! m_read_only ) && m_list.empty() )
92 m_buffer_empty.notify_one();
93 m_buffer_ready.wait(l);
95 if ( ! m_list.empty() )
104 template <
typename T>
106 shared_list<T>::push_back(
const T &v )
109 boost::thread::thread::yield();
119 if ( m_list.size() > 1000 )
122 m_buffer_empty.wait(l);
126 bool notify = m_list.empty() ? true :
false;
129 m_list.push_back( v );
133 m_buffer_ready.notify_one();
136 template <
typename T>
138 shared_list<T>::front()
143 if ( (! m_read_only ) && m_list.empty() )
144 m_buffer_ready.wait(l);
146 return m_list.front();
149 template <
typename T>
151 shared_list<T>::front()
const
156 if ( (! m_read_only) && m_list.empty() )
157 m_buffer_ready.wait(l);
159 return m_list.front();
161 template <
typename T>
163 shared_list<T>::empty()
168 if ( ( ! m_read_only ) && m_list.empty() )
169 m_buffer_ready.wait(l);
171 return m_list.empty();
173 template <
typename T>
175 shared_list<T>::set_read_only()
179 m_buffer_ready.notify_one();
Definition shared_list.hpp:24