Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r84650 - trunk/libs/circular_buffer/example
From: pbristow_at_[hidden]
Date: 2013-06-06 09:12:17


Author: pbristow
Date: 2013-06-06 09:12:16 EDT (Thu, 06 Jun 2013)
New Revision: 84650
URL: http://svn.boost.org/trac/boost/changeset/84650

Log:
Examples extracted from previous docs separated out, annotated with Quickbook snippets for use with new docs, and run with the new jamfile.

Added:
   trunk/libs/circular_buffer/example/
   trunk/libs/circular_buffer/example/bounded_buffer_comparison.cpp (contents, props changed)
   trunk/libs/circular_buffer/example/circular_buffer_bound_example.cpp (contents, props changed)
   trunk/libs/circular_buffer/example/circular_buffer_example.cpp (contents, props changed)
   trunk/libs/circular_buffer/example/circular_buffer_examples.bat (contents, props changed)
   trunk/libs/circular_buffer/example/circular_buffer_examples_06-Jun-2013_1300.log (contents, props changed)
   trunk/libs/circular_buffer/example/circular_buffer_iter_example.cpp (contents, props changed)
   trunk/libs/circular_buffer/example/circular_buffer_sum_example.cpp (contents, props changed)
   trunk/libs/circular_buffer/example/jamfile.v2 (contents, props changed)

Added: trunk/libs/circular_buffer/example/bounded_buffer_comparison.cpp
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ trunk/libs/circular_buffer/example/bounded_buffer_comparison.cpp 2013-06-06 09:12:16 EDT (Thu, 06 Jun 2013) (r84650)
@@ -0,0 +1,318 @@
+// Comparison of bounded buffers based on different containers.
+
+// Copyright (c) 2003-2008 Jan Gaspar
+// Copyright 2013 Paul A. Bristow. Added some Quickbook snippet markers.
+
+// Use, modification, and distribution is subject to the Boost Software
+// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#define BOOST_CB_DISABLE_DEBUG
+
+#include <boost/circular_buffer.hpp>
+#include <boost/thread/mutex.hpp>
+#include <boost/thread/condition.hpp>
+#include <boost/thread/thread.hpp>
+#include <boost/call_traits.hpp>
+#include <boost/progress.hpp>
+#include <boost/bind.hpp>
+#include <deque>
+#include <list>
+#include <string>
+#include <iostream>
+
+const unsigned long QUEUE_SIZE = 1000L;
+const unsigned long TOTAL_ELEMENTS = QUEUE_SIZE * 1000L;
+
+template <class T>
+class bounded_buffer {
+public:
+
+ typedef boost::circular_buffer<T> container_type;
+ typedef typename container_type::size_type size_type;
+ typedef typename container_type::value_type value_type;
+ typedef typename boost::call_traits<value_type>::param_type param_type;
+
+ explicit bounded_buffer(size_type capacity) : m_unread(0), m_container(capacity) {}
+
+ void push_front(param_type item) {
+ boost::mutex::scoped_lock lock(m_mutex);
+ m_not_full.wait(lock, boost::bind(&bounded_buffer<value_type>::is_not_full, this));
+ m_container.push_front(item);
+ ++m_unread;
+ lock.unlock();
+ m_not_empty.notify_one();
+ }
+
+ void pop_back(value_type* pItem) {
+ boost::mutex::scoped_lock lock(m_mutex);
+ m_not_empty.wait(lock, boost::bind(&bounded_buffer<value_type>::is_not_empty, this));
+ *pItem = m_container[--m_unread];
+ lock.unlock();
+ m_not_full.notify_one();
+ }
+
+private:
+ bounded_buffer(const bounded_buffer&); // Disabled copy constructor
+ bounded_buffer& operator = (const bounded_buffer&); // Disabled assign operator
+
+ bool is_not_empty() const { return m_unread > 0; }
+ bool is_not_full() const { return m_unread < m_container.capacity(); }
+
+ size_type m_unread;
+ container_type m_container;
+ boost::mutex m_mutex;
+ boost::condition m_not_empty;
+ boost::condition m_not_full;
+};
+
+template <class T>
+class bounded_buffer_space_optimized {
+public:
+
+ typedef boost::circular_buffer_space_optimized<T> container_type;
+ typedef typename container_type::size_type size_type;
+ typedef typename container_type::value_type value_type;
+ typedef typename boost::call_traits<value_type>::param_type param_type;
+
+ explicit bounded_buffer_space_optimized(size_type capacity) : m_container(capacity) {}
+
+ void push_front(param_type item) {
+ boost::mutex::scoped_lock lock(m_mutex);
+ m_not_full.wait(lock, boost::bind(&bounded_buffer_space_optimized<value_type>::is_not_full, this));
+ m_container.push_front(item);
+ lock.unlock();
+ m_not_empty.notify_one();
+ }
+
+ void pop_back(value_type* pItem) {
+ boost::mutex::scoped_lock lock(m_mutex);
+ m_not_empty.wait(lock, boost::bind(&bounded_buffer_space_optimized<value_type>::is_not_empty, this));
+ *pItem = m_container.back();
+ m_container.pop_back();
+ lock.unlock();
+ m_not_full.notify_one();
+ }
+
+private:
+
+ bounded_buffer_space_optimized(const bounded_buffer_space_optimized&); // Disabled copy constructor
+ bounded_buffer_space_optimized& operator = (const bounded_buffer_space_optimized&); // Disabled assign operator
+
+ bool is_not_empty() const { return m_container.size() > 0; }
+ bool is_not_full() const { return m_container.size() < m_container.capacity(); }
+
+ container_type m_container;
+ boost::mutex m_mutex;
+ boost::condition m_not_empty;
+ boost::condition m_not_full;
+};
+
+template <class T>
+class bounded_buffer_deque_based {
+public:
+
+ typedef std::deque<T> container_type;
+ typedef typename container_type::size_type size_type;
+ typedef typename container_type::value_type value_type;
+ typedef typename boost::call_traits<value_type>::param_type param_type;
+
+ explicit bounded_buffer_deque_based(size_type capacity) : m_capacity(capacity) {}
+
+ void push_front(param_type item) {
+ boost::mutex::scoped_lock lock(m_mutex);
+ m_not_full.wait(lock, boost::bind(&bounded_buffer_deque_based<value_type>::is_not_full, this));
+ m_container.push_front(item);
+ lock.unlock();
+ m_not_empty.notify_one();
+ }
+
+ void pop_back(value_type* pItem) {
+ boost::mutex::scoped_lock lock(m_mutex);
+ m_not_empty.wait(lock, boost::bind(&bounded_buffer_deque_based<value_type>::is_not_empty, this));
+ *pItem = m_container.back();
+ m_container.pop_back();
+ lock.unlock();
+ m_not_full.notify_one();
+ }
+
+private:
+
+ bounded_buffer_deque_based(const bounded_buffer_deque_based&); // Disabled copy constructor
+ bounded_buffer_deque_based& operator = (const bounded_buffer_deque_based&); // Disabled assign operator
+
+ bool is_not_empty() const { return m_container.size() > 0; }
+ bool is_not_full() const { return m_container.size() < m_capacity; }
+
+ const size_type m_capacity;
+ container_type m_container;
+ boost::mutex m_mutex;
+ boost::condition m_not_empty;
+ boost::condition m_not_full;
+};
+
+template <class T>
+class bounded_buffer_list_based {
+public:
+
+ typedef std::list<T> container_type;
+ typedef typename container_type::size_type size_type;
+ typedef typename container_type::value_type value_type;
+ typedef typename boost::call_traits<value_type>::param_type param_type;
+
+ explicit bounded_buffer_list_based(size_type capacity) : m_capacity(capacity) {}
+
+ void push_front(param_type item) {
+ boost::mutex::scoped_lock lock(m_mutex);
+ m_not_full.wait(lock, boost::bind(&bounded_buffer_list_based<value_type>::is_not_full, this));
+ m_container.push_front(item);
+ lock.unlock();
+ m_not_empty.notify_one();
+ }
+
+ void pop_back(value_type* pItem) {
+ boost::mutex::scoped_lock lock(m_mutex);
+ m_not_empty.wait(lock, boost::bind(&bounded_buffer_list_based<value_type>::is_not_empty, this));
+ *pItem = m_container.back();
+ m_container.pop_back();
+ lock.unlock();
+ m_not_full.notify_one();
+ }
+
+private:
+
+ bounded_buffer_list_based(const bounded_buffer_list_based&); // Disabled copy constructor
+ bounded_buffer_list_based& operator = (const bounded_buffer_list_based&); // Disabled assign operator
+
+ bool is_not_empty() const { return m_container.size() > 0; }
+ bool is_not_full() const { return m_container.size() < m_capacity; }
+
+ const size_type m_capacity;
+ container_type m_container;
+ boost::mutex m_mutex;
+ boost::condition m_not_empty;
+ boost::condition m_not_full;
+};
+
+template<class Buffer>
+class Consumer {
+
+ typedef typename Buffer::value_type value_type;
+ Buffer* m_container;
+ value_type m_item;
+
+public:
+ Consumer(Buffer* buffer) : m_container(buffer) {}
+
+ void operator()() {
+ for (unsigned long i = 0L; i < TOTAL_ELEMENTS; ++i) {
+ m_container->pop_back(&m_item);
+ }
+ }
+};
+
+template<class Buffer>
+class Producer {
+
+ typedef typename Buffer::value_type value_type;
+ Buffer* m_container;
+
+public:
+ Producer(Buffer* buffer) : m_container(buffer) {}
+
+ void operator()() {
+ for (unsigned long i = 0L; i < TOTAL_ELEMENTS; ++i) {
+ m_container->push_front(value_type());
+ }
+ }
+};
+
+template<class Buffer>
+void fifo_test(Buffer* buffer) {
+
+ // Start of measurement
+ boost::progress_timer progress;
+
+ // Initialize the buffer with some values before launching producer and consumer threads.
+ for (unsigned long i = QUEUE_SIZE / 2L; i > 0; --i) {
+#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x581))
+ buffer->push_front(Buffer::value_type());
+#else
+ buffer->push_front(BOOST_DEDUCED_TYPENAME Buffer::value_type());
+#endif
+ }
+
+ Consumer<Buffer> consumer(buffer);
+ Producer<Buffer> producer(buffer);
+
+ // Start the threads.
+ boost::thread consume(consumer);
+ boost::thread produce(producer);
+
+ // Wait for completion.
+ consume.join();
+ produce.join();
+
+ // End of measurement
+}
+
+int main(int /*argc*/, char* /*argv*/[]) {
+
+ bounded_buffer<int> bb_int(QUEUE_SIZE);
+ std::cout << "bounded_buffer<int> ";
+ fifo_test(&bb_int);
+
+ bounded_buffer_space_optimized<int> bb_space_optimized_int(QUEUE_SIZE);
+ std::cout << "bounded_buffer_space_optimized<int> ";
+ fifo_test(&bb_space_optimized_int);
+
+ bounded_buffer_deque_based<int> bb_deque_based_int(QUEUE_SIZE);
+ std::cout << "bounded_buffer_deque_based<int> ";
+ fifo_test(&bb_deque_based_int);
+
+ bounded_buffer_list_based<int> bb_list_based_int(QUEUE_SIZE);
+ std::cout << "bounded_buffer_list_based<int> ";
+ fifo_test(&bb_list_based_int);
+
+ bounded_buffer<std::string> bb_string(QUEUE_SIZE);
+ std::cout << "bounded_buffer<std::string> ";
+ fifo_test(&bb_string);
+
+ bounded_buffer_space_optimized<std::string> bb_space_optimized_string(QUEUE_SIZE);
+ std::cout << "bounded_buffer_space_optimized<std::string> ";
+ fifo_test(&bb_space_optimized_string);
+
+ bounded_buffer_deque_based<std::string> bb_deque_based_string(QUEUE_SIZE);
+ std::cout << "bounded_buffer_deque_based<std::string> ";
+ fifo_test(&bb_deque_based_string);
+
+ bounded_buffer_list_based<std::string> bb_list_based_string(QUEUE_SIZE);
+ std::cout << "bounded_buffer_list_based<std::string> ";
+ fifo_test(&bb_list_based_string);
+
+ return 0;
+}
+/*
+
+//[bounded_buffer_comparison_output
+
+ Description: Autorun "J:\Cpp\Misc\Debug\bounded_buffer_comparison.exe"
+ bounded_buffer<int> 5.15 s
+
+ bounded_buffer_space_optimized<int> 5.71 s
+
+ bounded_buffer_deque_based<int> 15.57 s
+
+ bounded_buffer_list_based<int> 17.33 s
+
+ bounded_buffer<std::string> 24.49 s
+
+ bounded_buffer_space_optimized<std::string> 28.33 s
+
+ bounded_buffer_deque_based<std::string> 29.45 s
+
+ bounded_buffer_list_based<std::string> 31.29 s
+
+ //] //[bounded_buffer_comparison_output]
+
+*/

Added: trunk/libs/circular_buffer/example/circular_buffer_bound_example.cpp
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ trunk/libs/circular_buffer/example/circular_buffer_bound_example.cpp 2013-06-06 09:12:16 EDT (Thu, 06 Jun 2013) (r84650)
@@ -0,0 +1,191 @@
+// Copyright 2003-2008 Jan Gaspar.
+// Copyright 2013 Paul A. Bristow. Added some Quickbook snippet markers.
+
+// Distributed under the Boost Software License, Version 1.0.
+// (See the accompanying file LICENSE_1_0.txt
+// or a copy at <http://www.boost.org/LICENSE_1_0.txt>.)
+
+//[circular_buffer_bound_example_1
+/*`
+This example shows how the `circular_buffer` can be utilized
+as an underlying container of the bounded buffer.
+*/
+
+#include <boost/circular_buffer.hpp>
+#include <boost/thread/mutex.hpp>
+#include <boost/thread/condition.hpp>
+#include <boost/thread/thread.hpp>
+#include <boost/call_traits.hpp>
+#include <boost/bind.hpp>
+
+#include <boost/timer/timer.hpp> // for auto_cpu_timer
+
+template <class T>
+class bounded_buffer
+{
+public:
+
+ typedef boost::circular_buffer<T> container_type;
+ typedef typename container_type::size_type size_type;
+ typedef typename container_type::value_type value_type;
+ typedef typename boost::call_traits<value_type>::param_type param_type;
+
+ explicit bounded_buffer(size_type capacity) : m_unread(0), m_container(capacity) {}
+
+ void push_front(typename boost::call_traits<value_type>::param_type item)
+ { // `param_type` represents the "best" way to pass a parameter of type `value_type` to a method.
+
+ boost::mutex::scoped_lock lock(m_mutex);
+ m_not_full.wait(lock, boost::bind(&bounded_buffer<value_type>::is_not_full, this));
+ m_container.push_front(item);
+ ++m_unread;
+ lock.unlock();
+ m_not_empty.notify_one();
+ }
+
+ void pop_back(value_type* pItem) {
+ boost::mutex::scoped_lock lock(m_mutex);
+ m_not_empty.wait(lock, boost::bind(&bounded_buffer<value_type>::is_not_empty, this));
+ *pItem = m_container[--m_unread];
+ lock.unlock();
+ m_not_full.notify_one();
+ }
+
+private:
+ bounded_buffer(const bounded_buffer&); // Disabled copy constructor.
+ bounded_buffer& operator = (const bounded_buffer&); // Disabled assign operator.
+
+ bool is_not_empty() const { return m_unread > 0; }
+ bool is_not_full() const { return m_unread < m_container.capacity(); }
+
+ size_type m_unread;
+ container_type m_container;
+ boost::mutex m_mutex;
+ boost::condition m_not_empty;
+ boost::condition m_not_full;
+}; //
+
+//] [/circular_buffer_bound_example_1]
+
+const unsigned long queue_size = 1000L;
+const unsigned long total_elements = queue_size * 1000L;
+
+//[circular_buffer_bound_example_2]
+/*`To demonstrate, create two classes to exercise the buffer.
+
+The producer class fills the buffer with elements.
+
+The consumer class consumes the buffer contents.
+
+*/
+
+template<class Buffer>
+class Producer
+{
+
+ typedef typename Buffer::value_type value_type;
+ Buffer* m_container;
+
+public:
+ Producer(Buffer* buffer) : m_container(buffer)
+ {}
+
+ void operator()()
+ {
+ for (unsigned long i = 0L; i < total_elements; ++i)
+ {
+ m_container->push_front(value_type());
+ }
+ }
+};
+
+template<class Buffer>
+class Consumer
+{
+
+ typedef typename Buffer::value_type value_type;
+ Buffer* m_container;
+ value_type m_item;
+
+public:
+ Consumer(Buffer* buffer) : m_container(buffer)
+ {}
+
+ void operator()()
+ {
+ for (unsigned long i = 0L; i < total_elements; ++i)
+ {
+ m_container->pop_back(&m_item);
+ }
+ }
+};
+
+/*`Create a first-int first-out test of the bound_buffer.
+Include a call to boost::progress_timer
+
+[@http://www.boost.org/doc/libs/1_53_0/libs/timer/doc/cpu_timers.html CPU timer]
+
+*/
+template<class Buffer>
+void fifo_test(Buffer* buffer)
+{
+ // Start of timing.
+ boost::timer::auto_cpu_timer progress;
+
+ // Initialize the buffer with some values before launching producer and consumer threads.
+ for (unsigned long i = queue_size / 2L; i > 0; --i)
+ {
+#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x581))
+ buffer->push_front(Buffer::value_type());
+#else
+ buffer->push_front(BOOST_DEDUCED_TYPENAME Buffer::value_type());
+#endif
+ }
+
+ // Construct the threads.
+ Consumer<Buffer> consumer(buffer);
+ Producer<Buffer> producer(buffer);
+
+ // Start the threads.
+ boost::thread consume(consumer);
+ boost::thread produce(producer);
+
+ // Wait for completion.
+ consume.join();
+ produce.join();
+
+ // End of timing.
+ // destructor of boost::timer::auto_cpu_timer will output the time to std::cout.
+
+}
+//] [/circular_buffer_bound_example_2]
+
+
+int main()
+{
+//[circular_buffer_bound_example_3]
+ //`Construct a bounded_buffer to hold the chosen type, here int.
+ bounded_buffer<int> bb_int(queue_size);
+ std::cout << "Testing bounded_buffer<int> ";
+
+ //`Start the fifo test.
+ fifo_test(&bb_int);
+ //` destructor of boost::timer::auto_cpu_timer will output the time to std::cout
+
+//] [/circular_buffer_bound_example_3]
+
+return 0;
+} // int main()
+
+/*
+
+//[circular_buffer_bound_output
+
+ Description: Autorun "J:\Cpp\Misc\Debug\circular_buffer_bound_example.exe"
+
+ Testing bounded_buffer<int> 15.010692s wall, 9.188459s user + 7.207246s system = 16.395705s CPU (109.2%)
+
+//] [/circular_buffer_bound_output]
+*/
+
+

Added: trunk/libs/circular_buffer/example/circular_buffer_example.cpp
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ trunk/libs/circular_buffer/example/circular_buffer_example.cpp 2013-06-06 09:12:16 EDT (Thu, 06 Jun 2013) (r84650)
@@ -0,0 +1,63 @@
+// Copyright 2003-2008 Jan Gaspar.
+// Copyright 2013 Paul A. Bristow. Added some Quickbook snippet markers.
+
+// Distributed under the Boost Software License, Version 1.0.
+// (See the accompanying file LICENSE_1_0.txt
+// or a copy at <http://www.boost.org/LICENSE_1_0.txt>.)
+
+//[circular_buffer_example_1
+/*`For all examples, we need this include:
+*/
+
+#include <boost/circular_buffer.hpp>
+
+//] [/circular_buffer_example_1]
+
+ int main()
+ {
+
+//[circular_buffer_example_2
+ // Create a circular buffer with a capacity for 3 integers.
+ boost::circular_buffer<int> cb(3);
+
+ // Insert threee elements into the buffer.
+ cb.push_back(1);
+ cb.push_back(2);
+ cb.push_back(3);
+
+ int a = cb[0]; // a == 1
+ int b = cb[1]; // b == 2
+ int c = cb[2]; // c == 3
+
+ // The buffer is full now, so pushing subsequent
+ // elements will overwrite the front-most elements.
+
+ cb.push_back(4); // Overwrite 1 with 4.
+ cb.push_back(5); // Overwrite 2 with 5.
+
+ // The buffer now contains 3, 4 and 5.
+ a = cb[0]; // a == 3
+ b = cb[1]; // b == 4
+ c = cb[2]; // c == 5
+
+ // Elements can be popped from either the front or the back.
+ cb.pop_back(); // 5 is removed.
+ cb.pop_front(); // 3 is removed.
+
+ // Leaving only one element with value = 4.
+ int d = cb[0]; // d == 4
+
+//] [/circular_buffer_example_2]
+ return 0;
+ }
+
+ /*
+
+ //[circular_buffer_example_output
+
+There is no output from this example.
+
+//] [/circular_buffer_example_output]
+
+ */
+

Added: trunk/libs/circular_buffer/example/circular_buffer_examples.bat
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ trunk/libs/circular_buffer/example/circular_buffer_examples.bat 2013-06-06 09:12:16 EDT (Thu, 06 Jun 2013) (r84650)
@@ -0,0 +1,14 @@
+echo off
+rem quickbook doxgen auto-index docs template circular_buffer_html_index.bat
+rem echo circular_buffer_html_index_%date%_%time:~0,2%_%time:~3,2%.log
+rem The DOS time format is assumed 12:34 and the : separator is not used.
+set t=%time% /T
+set tim=%t:~0,2%%t:~3,2%
+rem pick just hours and minutes.
+rem time may include leading space, like " 915", so remove space.
+set tim=%tim: =%
+rem boost-no-inspect
+rem cd \boost-trunk/circular_buffer\libs\circular_buffer\example
+bjam -a > circular_buffer_examples_%date%_%tim%.log
+if not ERRORLEVEL 0 (echo Errorlevel is %ERRORLEVEL%) else (echo OK)
+pause

Added: trunk/libs/circular_buffer/example/circular_buffer_examples_06-Jun-2013_1300.log
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ trunk/libs/circular_buffer/example/circular_buffer_examples_06-Jun-2013_1300.log 2013-06-06 09:12:16 EDT (Thu, 06 Jun 2013) (r84650)
@@ -0,0 +1,69 @@
+
+...patience...
+...found 1209 targets...
+...updating 44 targets...
+compile-c-c++ ..\..\..\bin.v2\libs\circular_buffer\example\bounded_buffer_comparison.test\msvc-10.0\debug\asynch-exceptions-on\threading-multi\bounded_buffer_comparison.obj
+bounded_buffer_comparison.cpp
+compile-c-c++ ..\..\..\bin.v2\libs\system\build\msvc-10.0\debug\asynch-exceptions-on\threading-multi\error_code.obj
+error_code.cpp
+msvc.link.dll ..\..\..\bin.v2\libs\system\build\msvc-10.0\debug\asynch-exceptions-on\threading-multi\boost_system-vc100-mt-gd-1_54.dll
+ Creating library ..\..\..\bin.v2\libs\system\build\msvc-10.0\debug\asynch-exceptions-on\threading-multi\boost_system-vc100-mt-gd-1_54.lib and object ..\..\..\bin.v2\libs\system\build\msvc-10.0\debug\asynch-exceptions-on\threading-multi\boost_system-vc100-mt-gd-1_54.exp
+msvc.manifest.dll ..\..\..\bin.v2\libs\system\build\msvc-10.0\debug\asynch-exceptions-on\threading-multi\boost_system-vc100-mt-gd-1_54.dll
+compile-c-c++ ..\..\..\bin.v2\libs\thread\build\msvc-10.0\debug\asynch-exceptions-on\threading-multi\win32\thread.obj
+thread.cpp
+compile-c-c++ ..\..\..\bin.v2\libs\thread\build\msvc-10.0\debug\asynch-exceptions-on\threading-multi\win32\tss_dll.obj
+tss_dll.cpp
+compile-c-c++ ..\..\..\bin.v2\libs\thread\build\msvc-10.0\debug\asynch-exceptions-on\threading-multi\win32\tss_pe.obj
+tss_pe.cpp
+compile-c-c++ ..\..\..\bin.v2\libs\thread\build\msvc-10.0\debug\asynch-exceptions-on\threading-multi\future.obj
+future.cpp
+msvc.link.dll ..\..\..\bin.v2\libs\thread\build\msvc-10.0\debug\asynch-exceptions-on\threading-multi\boost_thread-vc100-mt-gd-1_54.dll
+ Creating library ..\..\..\bin.v2\libs\thread\build\msvc-10.0\debug\asynch-exceptions-on\threading-multi\boost_thread-vc100-mt-gd-1_54.lib and object ..\..\..\bin.v2\libs\thread\build\msvc-10.0\debug\asynch-exceptions-on\threading-multi\boost_thread-vc100-mt-gd-1_54.exp
+msvc.manifest.dll ..\..\..\bin.v2\libs\thread\build\msvc-10.0\debug\asynch-exceptions-on\threading-multi\boost_thread-vc100-mt-gd-1_54.dll
+compile-c-c++ ..\..\..\bin.v2\libs\chrono\build\msvc-10.0\debug\asynch-exceptions-on\threading-multi\chrono.obj
+chrono.cpp
+compile-c-c++ ..\..\..\bin.v2\libs\chrono\build\msvc-10.0\debug\asynch-exceptions-on\threading-multi\thread_clock.obj
+thread_clock.cpp
+compile-c-c++ ..\..\..\bin.v2\libs\chrono\build\msvc-10.0\debug\asynch-exceptions-on\threading-multi\process_cpu_clocks.obj
+process_cpu_clocks.cpp
+msvc.link.dll ..\..\..\bin.v2\libs\chrono\build\msvc-10.0\debug\asynch-exceptions-on\threading-multi\boost_chrono-vc100-mt-gd-1_54.dll
+ Creating library ..\..\..\bin.v2\libs\chrono\build\msvc-10.0\debug\asynch-exceptions-on\threading-multi\boost_chrono-vc100-mt-gd-1_54.lib and object ..\..\..\bin.v2\libs\chrono\build\msvc-10.0\debug\asynch-exceptions-on\threading-multi\boost_chrono-vc100-mt-gd-1_54.exp
+msvc.manifest.dll ..\..\..\bin.v2\libs\chrono\build\msvc-10.0\debug\asynch-exceptions-on\threading-multi\boost_chrono-vc100-mt-gd-1_54.dll
+msvc.link ..\..\..\bin.v2\libs\circular_buffer\example\bounded_buffer_comparison.test\msvc-10.0\debug\asynch-exceptions-on\threading-multi\bounded_buffer_comparison.exe
+ Creating library ..\..\..\bin.v2\libs\circular_buffer\example\bounded_buffer_comparison.test\msvc-10.0\debug\asynch-exceptions-on\threading-multi\bounded_buffer_comparison.lib and object ..\..\..\bin.v2\libs\circular_buffer\example\bounded_buffer_comparison.test\msvc-10.0\debug\asynch-exceptions-on\threading-multi\bounded_buffer_comparison.exp
+msvc.manifest ..\..\..\bin.v2\libs\circular_buffer\example\bounded_buffer_comparison.test\msvc-10.0\debug\asynch-exceptions-on\threading-multi\bounded_buffer_comparison.exe
+testing.capture-output ..\..\..\bin.v2\libs\circular_buffer\example\bounded_buffer_comparison.test\msvc-10.0\debug\asynch-exceptions-on\threading-multi\bounded_buffer_comparison.run
+ 1 file(s) copied.
+**passed** ..\..\..\bin.v2\libs\circular_buffer\example\bounded_buffer_comparison.test\msvc-10.0\debug\asynch-exceptions-on\threading-multi\bounded_buffer_comparison.test
+compile-c-c++ ..\..\..\bin.v2\libs\circular_buffer\example\circular_buffer_iter_example.test\msvc-10.0\debug\asynch-exceptions-on\threading-multi\circular_buffer_iter_example.obj
+circular_buffer_iter_example.cpp
+msvc.link ..\..\..\bin.v2\libs\circular_buffer\example\circular_buffer_iter_example.test\msvc-10.0\debug\asynch-exceptions-on\threading-multi\circular_buffer_iter_example.exe
+msvc.manifest ..\..\..\bin.v2\libs\circular_buffer\example\circular_buffer_iter_example.test\msvc-10.0\debug\asynch-exceptions-on\threading-multi\circular_buffer_iter_example.exe
+testing.capture-output ..\..\..\bin.v2\libs\circular_buffer\example\circular_buffer_iter_example.test\msvc-10.0\debug\asynch-exceptions-on\threading-multi\circular_buffer_iter_example.run
+ 1 file(s) copied.
+**passed** ..\..\..\bin.v2\libs\circular_buffer\example\circular_buffer_iter_example.test\msvc-10.0\debug\asynch-exceptions-on\threading-multi\circular_buffer_iter_example.test
+compile-c-c++ ..\..\..\bin.v2\libs\circular_buffer\example\circular_buffer_sum_example.test\msvc-10.0\debug\asynch-exceptions-on\threading-multi\circular_buffer_sum_example.obj
+circular_buffer_sum_example.cpp
+msvc.link ..\..\..\bin.v2\libs\circular_buffer\example\circular_buffer_sum_example.test\msvc-10.0\debug\asynch-exceptions-on\threading-multi\circular_buffer_sum_example.exe
+msvc.manifest ..\..\..\bin.v2\libs\circular_buffer\example\circular_buffer_sum_example.test\msvc-10.0\debug\asynch-exceptions-on\threading-multi\circular_buffer_sum_example.exe
+testing.capture-output ..\..\..\bin.v2\libs\circular_buffer\example\circular_buffer_sum_example.test\msvc-10.0\debug\asynch-exceptions-on\threading-multi\circular_buffer_sum_example.run
+ 1 file(s) copied.
+**passed** ..\..\..\bin.v2\libs\circular_buffer\example\circular_buffer_sum_example.test\msvc-10.0\debug\asynch-exceptions-on\threading-multi\circular_buffer_sum_example.test
+compile-c-c++ ..\..\..\bin.v2\libs\circular_buffer\example\circular_buffer_bound_example.test\msvc-10.0\debug\asynch-exceptions-on\threading-multi\circular_buffer_bound_example.obj
+circular_buffer_bound_example.cpp
+common.mkdir ..\..\..\bin.v2\libs\timer\build\msvc-10.0\debug\asynch-exceptions-on
+common.mkdir ..\..\..\bin.v2\libs\timer\build\msvc-10.0\debug\asynch-exceptions-on\threading-multi
+compile-c-c++ ..\..\..\bin.v2\libs\timer\build\msvc-10.0\debug\asynch-exceptions-on\threading-multi\auto_timers_construction.obj
+auto_timers_construction.cpp
+compile-c-c++ ..\..\..\bin.v2\libs\timer\build\msvc-10.0\debug\asynch-exceptions-on\threading-multi\cpu_timer.obj
+cpu_timer.cpp
+msvc.link.dll ..\..\..\bin.v2\libs\timer\build\msvc-10.0\debug\asynch-exceptions-on\threading-multi\boost_timer-vc100-mt-gd-1_54.dll
+ Creating library ..\..\..\bin.v2\libs\timer\build\msvc-10.0\debug\asynch-exceptions-on\threading-multi\boost_timer-vc100-mt-gd-1_54.lib and object ..\..\..\bin.v2\libs\timer\build\msvc-10.0\debug\asynch-exceptions-on\threading-multi\boost_timer-vc100-mt-gd-1_54.exp
+msvc.manifest.dll ..\..\..\bin.v2\libs\timer\build\msvc-10.0\debug\asynch-exceptions-on\threading-multi\boost_timer-vc100-mt-gd-1_54.dll
+msvc.link ..\..\..\bin.v2\libs\circular_buffer\example\circular_buffer_bound_example.test\msvc-10.0\debug\asynch-exceptions-on\threading-multi\circular_buffer_bound_example.exe
+ Creating library ..\..\..\bin.v2\libs\circular_buffer\example\circular_buffer_bound_example.test\msvc-10.0\debug\asynch-exceptions-on\threading-multi\circular_buffer_bound_example.lib and object ..\..\..\bin.v2\libs\circular_buffer\example\circular_buffer_bound_example.test\msvc-10.0\debug\asynch-exceptions-on\threading-multi\circular_buffer_bound_example.exp
+msvc.manifest ..\..\..\bin.v2\libs\circular_buffer\example\circular_buffer_bound_example.test\msvc-10.0\debug\asynch-exceptions-on\threading-multi\circular_buffer_bound_example.exe
+testing.capture-output ..\..\..\bin.v2\libs\circular_buffer\example\circular_buffer_bound_example.test\msvc-10.0\debug\asynch-exceptions-on\threading-multi\circular_buffer_bound_example.run
+ 1 file(s) copied.
+**passed** ..\..\..\bin.v2\libs\circular_buffer\example\circular_buffer_bound_example.test\msvc-10.0\debug\asynch-exceptions-on\threading-multi\circular_buffer_bound_example.test
+...updated 44 targets...

Added: trunk/libs/circular_buffer/example/circular_buffer_iter_example.cpp
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ trunk/libs/circular_buffer/example/circular_buffer_iter_example.cpp 2013-06-06 09:12:16 EDT (Thu, 06 Jun 2013) (r84650)
@@ -0,0 +1,38 @@
+// Copyright 2003-2008 Jan Gaspar.
+// Copyright 2013 Paul A. Bristow. Added some Quickbook snippet markers.
+
+// Distributed under the Boost Software License, Version 1.0.
+// (See the accompanying file LICENSE_1_0.txt
+// or a copy at <http://www.boost.org/LICENSE_1_0.txt>.)
+
+//[circular_buffer_iter_example_1
+/*`
+*/
+
+#define BOOST_CB_DISABLE_DEBUG // The Debug Support has to be disabled, otherwise the code produces a runtime error.
+
+#include <boost/circular_buffer.hpp>
+#include <boost/assert.hpp>
+#include <assert.h>
+
+int main(int /*argc*/, char* /*argv*/[])
+{
+
+ boost::circular_buffer<int> cb(3);
+
+ cb.push_back(1);
+ cb.push_back(2);
+ cb.push_back(3);
+
+ boost::circular_buffer<int>::iterator it = cb.begin();
+
+ assert(*it == 1);
+
+ cb.push_back(4);
+
+ assert(*it == 4); // The iterator still points to the initialized memory.
+
+ return 0;
+}
+
+ //] [/circular_buffer_iter_example_1]

Added: trunk/libs/circular_buffer/example/circular_buffer_sum_example.cpp
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ trunk/libs/circular_buffer/example/circular_buffer_sum_example.cpp 2013-06-06 09:12:16 EDT (Thu, 06 Jun 2013) (r84650)
@@ -0,0 +1,64 @@
+// Copyright 2003-2008 Jan Gaspar.
+// Copyright 2013 Paul A. Bristow. Added some Quickbook snippet markers.
+
+// Distributed under the Boost Software License, Version 1.0.
+// (See the accompanying file LICENSE_1_0.txt
+// or a copy at <http://www.boost.org/LICENSE_1_0.txt>.)
+
+//[circular_buffer_sum_example_1
+
+/*`This example shows several functions, including summing all valid values.
+*/
+
+ #include <boost/circular_buffer.hpp>
+ #include <numeric>
+ #include <assert.h>
+
+ int main(int /*argc*/, char* /*argv*/[])
+ {
+ // Create a circular buffer of capacity 3.
+ boost::circular_buffer<int> cb(3);
+ assert(cb.capacity() == 3);
+ // Check is empty.
+ assert(cb.size() == 0);
+ assert(cb.empty());
+
+ // Insert some elements into the circular buffer.
+ cb.push_back(1);
+ cb.push_back(2);
+
+ // Assertions to check push_backs have expected effect.
+ assert(cb[0] == 1);
+ assert(cb[1] == 2);
+ assert(!cb.full());
+ assert(cb.size() == 2);
+ assert(cb.capacity() == 3);
+
+ // Insert some other elements.
+ cb.push_back(3);
+ cb.push_back(4);
+
+ // Evaluate the sum of all elements.
+ int sum = std::accumulate(cb.begin(), cb.end(), 0);
+
+ // Assertions to check state.
+ assert(sum == 9);
+ assert(cb[0] == 2);
+ assert(cb[1] == 3);
+ assert(cb[2] == 4);
+ assert(*cb.begin() == 2);
+ assert(cb.front() == 2);
+ assert(cb.back() == 4);
+ assert(cb.full());
+ assert(cb.size() == 3);
+ assert(cb.capacity() == 3);
+
+ return 0;
+ }
+
+ //] [/circular_buffer_sum_example_1]
+
+
+ /*
+ There is no output from this example.
+ */

Added: trunk/libs/circular_buffer/example/jamfile.v2
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ trunk/libs/circular_buffer/example/jamfile.v2 2013-06-06 09:12:16 EDT (Thu, 06 Jun 2013) (r84650)
@@ -0,0 +1,42 @@
+# Copyright Paul A. Bristow 2013
+
+# Distributed under the Boost Software License, Version 1.0.
+# (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+# jamfile.v2 to run all circular_buffer examples.
+
+# bring in the rules for testing.
+import testing ;
+
+project
+ : requirements
+ <library>/boost/system//boost_system
+ <library>/boost/thread//boost_thread
+ #<define>BOOST_ALL_NO_LIB=1
+ <threading>multi
+
+ <toolset>gcc:<cxxflags>-Wno-missing-braces
+ <toolset>darwin:<cxxflags>-Wno-missing-braces
+ <toolset>acc:<cxxflags>+W2068,2461,2236,4070
+ <toolset>intel:<cxxflags>-Qwd264,239
+ <toolset>msvc:<warnings>all
+ <toolset>msvc:<asynch-exceptions>on
+ <toolset>msvc:<define>_CRT_SECURE_NO_DEPRECATE
+ <toolset>msvc:<define>_SCL_SECURE_NO_DEPRECATE
+ <toolset>msvc:<define>_SCL_SECURE_NO_WARNINGS
+ <toolset>msvc:<define>_CRT_SECURE_NO_WARNINGS
+ <toolset>msvc:<cxxflags>/wd4996
+ <toolset>msvc:<cxxflags>/wd4512
+ <toolset>msvc:<cxxflags>/wd4610
+ <toolset>msvc:<cxxflags>/wd4510
+ <toolset>msvc:<cxxflags>/wd4127
+ <toolset>msvc:<cxxflags>/wd4701
+ <toolset>msvc:<cxxflags>/wd4127
+ <toolset>msvc:<cxxflags>/wd4305
+ ;
+
+run bounded_buffer_comparison.cpp ;
+run circular_buffer_iter_example.cpp ;
+run circular_buffer_sum_example.cpp ;
+run circular_buffer_bound_example.cpp ../../thread/build//boost_thread ../../timer/build//boost_timer ;
+


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk