Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r59110 - in branches/release: . boost boost/algorithm/string boost/archive boost/asio boost/bimap boost/config boost/filesystem boost/functional/hash boost/fusion boost/graph boost/integer boost/interprocess boost/intrusive boost/iostreams boost/math boost/numeric/ublas boost/program_options boost/property_tree boost/python boost/regex boost/serialization boost/signals boost/signals2 boost/spirit boost/spirit/home boost/spirit/home/karma boost/spirit/home/support boost/statechart boost/system boost/thread boost/tr1 boost/type_traits boost/unordered boost/utility boost/uuid boost/variant boost/wave doc libs libs/array/doc libs/asio/doc libs/asio/example/http/server4 libs/bimap libs/config libs/filesystem libs/functional/hash libs/fusion libs/graph_parallel libs/integer libs/interprocess libs/intrusive libs/iostreams libs/math libs/mpl/doc/refmanual libs/mpl/doc/src/refmanual libs/numeric/ublas libs/numeric/ublas/doc libs/program_options libs/property_tree libs/python libs/regex libs/regex/doc libs/serialization libs/signals libs/signals2 libs/spirit libs/spirit/classic/example libs/spirit/doc libs/spirit/example libs/spirit/phoenix libs/spirit/test libs/spirit/test/qi libs/statechart libs/static_assert libs/system libs/thread libs/thread/doc libs/timer libs/tr1 libs/type_traits libs/unordered libs/utility libs/uuid libs/wave more people status tools tools/bcp tools/boostbook tools/build/v2 tools/inspect tools/quickbook tools/regression tools/release tools/wave wiki
From: chris_at_[hidden]
Date: 2010-01-17 21:35:34


Author: chris_kohlhoff
Date: 2010-01-17 21:35:32 EST (Sun, 17 Jan 2010)
New Revision: 59110
URL: http://svn.boost.org/trac/boost/changeset/59110

Log:
Merge doc and example changes from trunk.

........
  r58900 | chris_kohlhoff | 2010-01-11 23:22:33 +1100 (Mon, 11 Jan 2010) | 2 lines
  
  Add HTTP Server 4 example.
........
  r59103 | chris_kohlhoff | 2010-01-18 08:42:36 +1100 (Mon, 18 Jan 2010) | 2 lines
  
  Add coroutine::is_complete() and support for "yield break;".
........
  r59104 | chris_kohlhoff | 2010-01-18 08:48:17 +1100 (Mon, 18 Jan 2010) | 2 lines
  
  Document ordering of handlers in strands. Fix error in streambuf snippet.
........
  r59106 | chris_kohlhoff | 2010-01-18 09:21:21 +1100 (Mon, 18 Jan 2010) | 2 lines
  
  Update revision history.
........

Added:
   branches/release/libs/asio/example/http/server4/
      - copied from r58900, /trunk/libs/asio/example/http/server4/
   branches/release/libs/asio/example/http/server4/Jamfile
      - copied unchanged from r58900, /trunk/libs/asio/example/http/server4/Jamfile
   branches/release/libs/asio/example/http/server4/Jamfile.v2
      - copied unchanged from r58900, /trunk/libs/asio/example/http/server4/Jamfile.v2
   branches/release/libs/asio/example/http/server4/coroutine.hpp
      - copied, changed from r58900, /trunk/libs/asio/example/http/server4/coroutine.hpp
   branches/release/libs/asio/example/http/server4/file_handler.cpp
      - copied unchanged from r58900, /trunk/libs/asio/example/http/server4/file_handler.cpp
   branches/release/libs/asio/example/http/server4/file_handler.hpp
      - copied unchanged from r58900, /trunk/libs/asio/example/http/server4/file_handler.hpp
   branches/release/libs/asio/example/http/server4/header.hpp
      - copied unchanged from r58900, /trunk/libs/asio/example/http/server4/header.hpp
   branches/release/libs/asio/example/http/server4/mime_types.cpp
      - copied unchanged from r58900, /trunk/libs/asio/example/http/server4/mime_types.cpp
   branches/release/libs/asio/example/http/server4/mime_types.hpp
      - copied unchanged from r58900, /trunk/libs/asio/example/http/server4/mime_types.hpp
   branches/release/libs/asio/example/http/server4/posix_main.cpp
      - copied unchanged from r58900, /trunk/libs/asio/example/http/server4/posix_main.cpp
   branches/release/libs/asio/example/http/server4/reply.cpp
      - copied unchanged from r58900, /trunk/libs/asio/example/http/server4/reply.cpp
   branches/release/libs/asio/example/http/server4/reply.hpp
      - copied unchanged from r58900, /trunk/libs/asio/example/http/server4/reply.hpp
   branches/release/libs/asio/example/http/server4/request.hpp
      - copied unchanged from r58900, /trunk/libs/asio/example/http/server4/request.hpp
   branches/release/libs/asio/example/http/server4/request_parser.cpp
      - copied unchanged from r58900, /trunk/libs/asio/example/http/server4/request_parser.cpp
   branches/release/libs/asio/example/http/server4/request_parser.hpp
      - copied unchanged from r58900, /trunk/libs/asio/example/http/server4/request_parser.hpp
   branches/release/libs/asio/example/http/server4/server.cpp
      - copied unchanged from r58900, /trunk/libs/asio/example/http/server4/server.cpp
   branches/release/libs/asio/example/http/server4/server.hpp
      - copied unchanged from r58900, /trunk/libs/asio/example/http/server4/server.hpp
   branches/release/libs/asio/example/http/server4/unyield.hpp
      - copied unchanged from r58900, /trunk/libs/asio/example/http/server4/unyield.hpp
   branches/release/libs/asio/example/http/server4/win_main.cpp
      - copied unchanged from r58900, /trunk/libs/asio/example/http/server4/win_main.cpp
   branches/release/libs/asio/example/http/server4/yield.hpp
      - copied unchanged from r58900, /trunk/libs/asio/example/http/server4/yield.hpp
Properties modified:
   branches/release/ (props changed)
   branches/release/CMakeLists.txt (props changed)
   branches/release/INSTALL (props changed)
   branches/release/Jamroot (props changed)
   branches/release/LICENSE_1_0.txt (props changed)
   branches/release/boost/ (props changed)
   branches/release/boost-build.jam (props changed)
   branches/release/boost.css (props changed)
   branches/release/boost.png (props changed)
   branches/release/boost/algorithm/string/ (props changed)
   branches/release/boost/archive/ (props changed)
   branches/release/boost/array.hpp (props changed)
   branches/release/boost/bimap/ (props changed)
   branches/release/boost/config/ (props changed)
   branches/release/boost/filesystem/ (props changed)
   branches/release/boost/functional/hash/ (props changed)
   branches/release/boost/fusion/ (props changed)
   branches/release/boost/graph/ (props changed)
   branches/release/boost/integer/ (props changed)
   branches/release/boost/interprocess/ (props changed)
   branches/release/boost/intrusive/ (props changed)
   branches/release/boost/iostreams/ (props changed)
   branches/release/boost/math/ (props changed)
   branches/release/boost/numeric/ublas/ (props changed)
   branches/release/boost/program_options/ (props changed)
   branches/release/boost/property_tree/ (props changed)
   branches/release/boost/python/ (props changed)
   branches/release/boost/regex/ (props changed)
   branches/release/boost/serialization/ (props changed)
   branches/release/boost/signals/ (props changed)
   branches/release/boost/signals2/ (props changed)
   branches/release/boost/spirit/ (props changed)
   branches/release/boost/spirit/home/ (props changed)
   branches/release/boost/spirit/home/karma/ (props changed)
   branches/release/boost/spirit/home/support/attributes.hpp (props changed)
   branches/release/boost/statechart/ (props changed)
   branches/release/boost/system/ (props changed)
   branches/release/boost/thread/ (props changed)
   branches/release/boost/thread.hpp (props changed)
   branches/release/boost/tr1/ (props changed)
   branches/release/boost/type_traits/ (props changed)
   branches/release/boost/unordered/ (props changed)
   branches/release/boost/utility/value_init.hpp (props changed)
   branches/release/boost/uuid/ (props changed)
   branches/release/boost/variant/ (props changed)
   branches/release/boost/version.hpp (props changed)
   branches/release/boost/wave/ (props changed)
   branches/release/bootstrap.bat (props changed)
   branches/release/bootstrap.sh (props changed)
   branches/release/doc/ (props changed)
   branches/release/index.htm (props changed)
   branches/release/index.html (props changed)
   branches/release/libs/ (props changed)
   branches/release/libs/array/doc/array.xml (props changed)
   branches/release/libs/bimap/ (props changed)
   branches/release/libs/config/ (props changed)
   branches/release/libs/filesystem/ (props changed)
   branches/release/libs/functional/hash/ (props changed)
   branches/release/libs/fusion/ (props changed)
   branches/release/libs/graph_parallel/ (props changed)
   branches/release/libs/integer/ (props changed)
   branches/release/libs/interprocess/ (props changed)
   branches/release/libs/intrusive/ (props changed)
   branches/release/libs/iostreams/ (props changed)
   branches/release/libs/libraries.htm (props changed)
   branches/release/libs/maintainers.txt (props changed)
   branches/release/libs/math/ (props changed)
   branches/release/libs/mpl/doc/refmanual/broken-compiler-workarounds.html (props changed)
   branches/release/libs/mpl/doc/refmanual/categorized-index-concepts.html (props changed)
   branches/release/libs/mpl/doc/refmanual/cfg-no-preprocessed-headers.html (props changed)
   branches/release/libs/mpl/doc/refmanual/composition-and-argument-binding.html (props changed)
   branches/release/libs/mpl/doc/refmanual/data-types-concepts.html (props changed)
   branches/release/libs/mpl/doc/refmanual/data-types-miscellaneous.html (props changed)
   branches/release/libs/mpl/doc/refmanual/extensible-associative-sequence.html (props changed)
   branches/release/libs/mpl/doc/refmanual/inserter-class.html (props changed)
   branches/release/libs/mpl/doc/refmanual/tag-dispatched-metafunction.html (props changed)
   branches/release/libs/mpl/doc/refmanual/trivial-metafunctions-summary.html (props changed)
   branches/release/libs/mpl/doc/src/refmanual/Iterators-Iterator.rst (props changed)
   branches/release/libs/numeric/ublas/ (props changed)
   branches/release/libs/numeric/ublas/doc/ (props changed)
   branches/release/libs/program_options/ (props changed)
   branches/release/libs/property_tree/ (props changed)
   branches/release/libs/python/ (props changed)
   branches/release/libs/regex/ (props changed)
   branches/release/libs/regex/doc/ (props changed)
   branches/release/libs/serialization/ (props changed)
   branches/release/libs/signals/ (props changed)
   branches/release/libs/signals2/ (props changed)
   branches/release/libs/spirit/ (props changed)
   branches/release/libs/spirit/classic/example/ (props changed)
   branches/release/libs/spirit/doc/ (props changed)
   branches/release/libs/spirit/example/ (props changed)
   branches/release/libs/spirit/phoenix/ (props changed)
   branches/release/libs/spirit/test/ (props changed)
   branches/release/libs/spirit/test/qi/optional.cpp (props changed)
   branches/release/libs/statechart/ (props changed)
   branches/release/libs/static_assert/ (props changed)
   branches/release/libs/system/ (props changed)
   branches/release/libs/thread/ (props changed)
   branches/release/libs/thread/doc/ (props changed)
   branches/release/libs/timer/ (props changed)
   branches/release/libs/tr1/ (props changed)
   branches/release/libs/type_traits/ (props changed)
   branches/release/libs/unordered/ (props changed)
   branches/release/libs/utility/swap.html (props changed)
   branches/release/libs/utility/value_init.htm (props changed)
   branches/release/libs/utility/value_init_test.cpp (props changed)
   branches/release/libs/uuid/ (props changed)
   branches/release/libs/wave/ (props changed)
   branches/release/more/ (props changed)
   branches/release/people/ (props changed)
   branches/release/rst.css (props changed)
   branches/release/status/ (props changed)
   branches/release/status/Jamfile.v2 (props changed)
   branches/release/tools/ (props changed)
   branches/release/tools/bcp/ (props changed)
   branches/release/tools/boostbook/ (props changed)
   branches/release/tools/build/v2/ (props changed)
   branches/release/tools/inspect/ (props changed)
   branches/release/tools/quickbook/ (props changed)
   branches/release/tools/regression/ (props changed)
   branches/release/tools/release/ (props changed)
   branches/release/tools/wave/ (props changed)
   branches/release/wiki/ (props changed)
Text files modified:
   branches/release/boost/asio/basic_streambuf.hpp | 2
   branches/release/boost/asio/strand.hpp | 40 +++++++++++++++++
   branches/release/libs/asio/doc/Jamfile.v2 | 6 +-
   branches/release/libs/asio/doc/examples.qbk | 23 ++++++++++
   branches/release/libs/asio/doc/history.qbk | 33 ++++++++++++++
   branches/release/libs/asio/doc/reference.qbk | 92 +++++++++++++++++++++++++++++++++++++++
   branches/release/libs/asio/example/http/server4/coroutine.hpp | 21 ++++++--
   7 files changed, 205 insertions(+), 12 deletions(-)

Modified: branches/release/boost/asio/basic_streambuf.hpp
==============================================================================
--- branches/release/boost/asio/basic_streambuf.hpp (original)
+++ branches/release/boost/asio/basic_streambuf.hpp 2010-01-17 21:35:32 EST (Sun, 17 Jan 2010)
@@ -96,7 +96,7 @@
  * boost::asio::streambuf b;
  *
  * // reserve 512 bytes in output sequence
- * boost::asio::streambuf::const_buffers_type bufs = b.prepare(512);
+ * boost::asio::streambuf::mutable_buffers_type bufs = b.prepare(512);
  *
  * size_t n = sock.receive(bufs);
  *

Modified: branches/release/boost/asio/strand.hpp
==============================================================================
--- branches/release/boost/asio/strand.hpp (original)
+++ branches/release/boost/asio/strand.hpp 2010-01-17 21:35:32 EST (Sun, 17 Jan 2010)
@@ -30,6 +30,46 @@
  * handlers with the guarantee that none of those handlers will execute
  * concurrently.
  *
+ * @par Order of handler invocation
+ * Given:
+ *
+ * @li a strand object @c s
+ *
+ * @li an object @c a meeting completion handler requirements
+ *
+ * @li an object @c a1 which is an arbitrary copy of @c a made by the
+ * implementation
+ *
+ * @li an object @c b meeting completion handler requirements
+ *
+ * @li an object @c b1 which is an arbitrary copy of @c b made by the
+ * implementation
+ *
+ * if any of the following conditions are true:
+ *
+ * @li @c s.post(a) happens-before @c s.post(b)
+ *
+ * @li @c s.post(a) happens-before @c s.dispatch(b), where the latter is
+ * performed outside the strand
+ *
+ * @li @c s.dispatch(a) happens-before @c s.post(b), where the former is
+ * performed outside the strand
+ *
+ * @li @c s.dispatch(a) happens-before @c s.dispatch(b), where both are
+ * performed outside the strand
+ *
+ * then @c asio_handler_invoke(a1, &a1) happens-before
+ * @c asio_handler_invoke(b1, &b1).
+ *
+ * Note that in the following case:
+ * @code async_op_1(..., s.wrap(a));
+ * async_op_2(..., s.wrap(b)); @endcode
+ * the completion of the first async operation will perform @c s.dispatch(a),
+ * and the second will perform @c s.dispatch(b), but the order in which those
+ * are performed is unspecified. That is, you cannot state whether one
+ * happens-before the other. Therefore none of the above conditions are met and
+ * no ordering guarantee is made.
+ *
  * @par Thread Safety
  * @e Distinct @e objects: Safe._at_n
  * @e Shared @e objects: Safe.

Modified: branches/release/libs/asio/doc/Jamfile.v2
==============================================================================
--- branches/release/libs/asio/doc/Jamfile.v2 (original)
+++ branches/release/libs/asio/doc/Jamfile.v2 2010-01-17 21:35:32 EST (Sun, 17 Jan 2010)
@@ -33,9 +33,9 @@
   ;
 
 local example-names = allocation buffers chat echo http/client http/server
- http/server2 http/server3 icmp invocation iostreams local multicast
- nonblocking porthopper serialization services socks4 ssl timeouts timers
- windows ;
+ http/server2 http/server3 http/server4 icmp invocation iostreams local
+ multicast nonblocking porthopper serialization services socks4 ssl timeouts
+ timers windows ;
 
 for local l in $(example-names)
 {

Modified: branches/release/libs/asio/doc/examples.qbk
==============================================================================
--- branches/release/libs/asio/doc/examples.qbk (original)
+++ branches/release/libs/asio/doc/examples.qbk 2010-01-17 21:35:32 EST (Sun, 17 Jan 2010)
@@ -135,6 +135,29 @@
 * [@boost_asio/example/http/server3/win_main.cpp]
 
 
+[heading HTTP Server 4]
+
+A single-threaded HTTP server implemented using stackless coroutines.
+
+* [@boost_asio/example/http/server4/coroutine.hpp]
+* [@boost_asio/example/http/server4/file_handler.cpp]
+* [@boost_asio/example/http/server4/file_handler.hpp]
+* [@boost_asio/example/http/server4/header.hpp]
+* [@boost_asio/example/http/server4/mime_types.cpp]
+* [@boost_asio/example/http/server4/mime_types.hpp]
+* [@boost_asio/example/http/server4/posix_main.cpp]
+* [@boost_asio/example/http/server4/reply.cpp]
+* [@boost_asio/example/http/server4/reply.hpp]
+* [@boost_asio/example/http/server4/request.hpp]
+* [@boost_asio/example/http/server4/request_parser.cpp]
+* [@boost_asio/example/http/server4/request_parser.hpp]
+* [@boost_asio/example/http/server4/server.cpp]
+* [@boost_asio/example/http/server4/server.hpp]
+* [@boost_asio/example/http/server4/unyield.hpp]
+* [@boost_asio/example/http/server4/win_main.cpp]
+* [@boost_asio/example/http/server4/yield.hpp]
+
+
 [heading ICMP]
 
 This example shows how to use raw sockets with ICMP to ping a remote host.

Modified: branches/release/libs/asio/doc/history.qbk
==============================================================================
--- branches/release/libs/asio/doc/history.qbk (original)
+++ branches/release/libs/asio/doc/history.qbk 2010-01-17 21:35:32 EST (Sun, 17 Jan 2010)
@@ -7,6 +7,39 @@
 
 [section:history Revision History]
 
+[heading Asio 1.4.4 / Boost 1.42]
+
+* Added a new HTTP Server 4 example illustrating the use of stackless coroutines
+ with Asio.
+* Changed handler allocation and invocation to use `boost::addressof` to get the
+ address of handler objects, rather than applying `operator&` directly
+ ([@https://svn.boost.org/trac/boost/ticket/2977 #2977]).
+* Restricted MSVC buffer debugging workaround to 2008, as it causes a crash with
+ 2010 beta 2 ([@https://svn.boost.org/trac/boost/ticket/3796 #3796],
+ [@https://svn.boost.org/trac/boost/ticket/3822 #3822]).
+* Fixed a problem with the lifetime of handler memory, where Windows needs the
+ `OVERLAPPED` structure to be valid until both the initiating function call
+ has returned and the completion packet has been delivered.
+* Don't block signals while performing system calls, but instead restart the
+ calls if they are interrupted.
+* Documented the guarantee made by strand objects with respect to order of
+ handler invocation.
+* Changed strands to use a pool of implementations, to make copying of strands
+ cheaper.
+* Ensured that kqueue support is enabled for BSD platforms
+ ([@https://svn.boost.org/trac/boost/ticket/3626 #3626]).
+* Added a `boost_` prefix to the `extern "C"` thread entry point function
+ ([@https://svn.boost.org/trac/boost/ticket/3809 #3809]).
+* In `getaddrinfo` emulation, only check the socket type (`SOCK_STREAM` or
+ `SOCK_DGRAM`) if a service name has been specified. This should allow the
+ emulation to work with raw sockets.
+* Added a workaround for some broken Windows firewalls that make a socket
+ appear bound to 0.0.0.0 when it is in fact bound to 127.0.0.1.
+* Applied a fix for reported excessive CPU usage under Solaris
+ ([@https://svn.boost.org/trac/boost/ticket/3670 #3670]).
+* Added some support for platforms that use older compilers such as g++ 2.95
+ ([@https://svn.boost.org/trac/boost/ticket/3743 #3743]).
+
 [heading Asio 1.4.3 / Boost 1.40]
 
 * Added a new ping example to illustrate the use of ICMP sockets.

Modified: branches/release/libs/asio/doc/reference.qbk
==============================================================================
--- branches/release/libs/asio/doc/reference.qbk (original)
+++ branches/release/libs/asio/doc/reference.qbk 2010-01-17 21:35:32 EST (Sun, 17 Jan 2010)
@@ -30284,7 +30284,7 @@
    boost::asio::streambuf b;
 
    // reserve 512 bytes in output sequence
- boost::asio::streambuf::const_buffers_type bufs = b.prepare(512);
+ boost::asio::streambuf::mutable_buffers_type bufs = b.prepare(512);
 
    size_t n = sock.receive(bufs);
 
@@ -37994,6 +37994,50 @@
 The [link boost_asio.reference.io_service__strand `io_service::strand`] class provides the ability to post and dispatch handlers with the guarantee that none of those handlers will execute concurrently.
 
 
+[heading Order of handler invocation]
+
+Given:
+
+
+* a strand object s
+
+
+* an object a meeting completion handler requirements
+
+
+* an object a1 which is an arbitrary copy of a made by the implementation
+
+
+* an object b meeting completion handler requirements
+
+
+* an object b1 which is an arbitrary copy of b made by the implementation
+
+if any of the following conditions are true:
+
+
+* s.post(a) happens-before s.post(b)
+
+
+* s.post(a) happens-before s.dispatch(b), where the latter is performed outside the strand
+
+
+* s.dispatch(a) happens-before s.post(b), where the former is performed outside the strand
+
+
+* s.dispatch(a) happens-before s.dispatch(b), where both are performed outside the strand
+
+then `asio_handler_invoke(a1, &a1)` happens-before `asio_handler_invoke(b1, &b1)`.
+
+Note that in the following case:
+
+ async_op_1(..., s.wrap(a));
+ async_op_2(..., s.wrap(b));
+
+
+the completion of the first async operation will perform `s.dispatch(a)`, and the second will perform `s.dispatch(b)`, but the order in which those are performed is unspecified. That is, you cannot state whether one happens-before the other. Therefore none of the above conditions are met and no ordering guarantee is made.
+
+
 [heading Thread Safety]
   
 [*Distinct] [*objects:] Safe.
@@ -64243,6 +64287,50 @@
 The [link boost_asio.reference.io_service__strand `io_service::strand`] class provides the ability to post and dispatch handlers with the guarantee that none of those handlers will execute concurrently.
 
 
+[heading Order of handler invocation]
+
+Given:
+
+
+* a strand object s
+
+
+* an object a meeting completion handler requirements
+
+
+* an object a1 which is an arbitrary copy of a made by the implementation
+
+
+* an object b meeting completion handler requirements
+
+
+* an object b1 which is an arbitrary copy of b made by the implementation
+
+if any of the following conditions are true:
+
+
+* s.post(a) happens-before s.post(b)
+
+
+* s.post(a) happens-before s.dispatch(b), where the latter is performed outside the strand
+
+
+* s.dispatch(a) happens-before s.post(b), where the former is performed outside the strand
+
+
+* s.dispatch(a) happens-before s.dispatch(b), where both are performed outside the strand
+
+then `asio_handler_invoke(a1, &a1)` happens-before `asio_handler_invoke(b1, &b1)`.
+
+Note that in the following case:
+
+ async_op_1(..., s.wrap(a));
+ async_op_2(..., s.wrap(b));
+
+
+the completion of the first async operation will perform `s.dispatch(a)`, and the second will perform `s.dispatch(b)`, but the order in which those are performed is unspecified. That is, you cannot state whether one happens-before the other. Therefore none of the above conditions are met and no ordering guarantee is made.
+
+
 [heading Thread Safety]
   
 [*Distinct] [*objects:] Safe.
@@ -65167,7 +65255,7 @@
    boost::asio::streambuf b;
 
    // reserve 512 bytes in output sequence
- boost::asio::streambuf::const_buffers_type bufs = b.prepare(512);
+ boost::asio::streambuf::mutable_buffers_type bufs = b.prepare(512);
 
    size_t n = sock.receive(bufs);
 

Copied: branches/release/libs/asio/example/http/server4/coroutine.hpp (from r58900, /trunk/libs/asio/example/http/server4/coroutine.hpp)
==============================================================================
--- /trunk/libs/asio/example/http/server4/coroutine.hpp (original)
+++ branches/release/libs/asio/example/http/server4/coroutine.hpp 2010-01-17 21:35:32 EST (Sun, 17 Jan 2010)
@@ -17,6 +17,7 @@
   coroutine() : value_(0) {}
   bool is_child() const { return value_ < 0; }
   bool is_parent() const { return !is_child(); }
+ bool is_complete() const { return value_ == -1; }
 private:
   friend class coroutine_ref;
   int value_;
@@ -25,19 +26,24 @@
 class coroutine_ref
 {
 public:
- coroutine_ref(coroutine& c) : value_(c.value_) {}
- coroutine_ref(coroutine* c) : value_(c->value_) {}
+ coroutine_ref(coroutine& c) : value_(c.value_), modified_(false) {}
+ coroutine_ref(coroutine* c) : value_(c->value_), modified_(false) {}
+ ~coroutine_ref() { if (!modified_) value_ = -1; }
   operator int() const { return value_; }
- int& operator=(int v) { return value_ = v; }
+ int& operator=(int v) { modified_ = true; return value_ = v; }
 private:
   void operator=(const coroutine_ref&);
   int& value_;
+ bool modified_;
 };
 
 #define CORO_REENTER(c) \
   switch (coroutine_ref _coro_value = c) \
     case -1: if (_coro_value) \
     { \
+ goto terminate_coroutine; \
+ terminate_coroutine: \
+ _coro_value = -1; \
       goto bail_out_of_coroutine; \
       bail_out_of_coroutine: \
       break; \
@@ -54,9 +60,12 @@
     else \
       switch (_coro_value ? 0 : 1) \
         for (;;) \
- case 1: if (_coro_value) \
- goto bail_out_of_coroutine; \
- else case 0:
+ case -1: if (_coro_value) \
+ goto terminate_coroutine; \
+ else for (;;) \
+ case 1: if (_coro_value) \
+ goto bail_out_of_coroutine; \
+ else case 0:
 
 #define CORO_FORK \
   for (_coro_value = -__LINE__;; _coro_value = __LINE__) \


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