$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r85139 - in trunk: boost/coroutine boost/coroutine/v1/detail boost/coroutine/v2 boost/coroutine/v2/detail libs/coroutine/build libs/coroutine/example/cpp03 libs/coroutine/example/cpp11 libs/coroutine/src libs/coroutine/test
From: oliver.kowalke_at_[hidden]
Date: 2013-07-23 15:49:38
Author: olli
Date: 2013-07-23 15:49:38 EDT (Tue, 23 Jul 2013)
New Revision: 85139
URL: http://svn.boost.org/trac/boost/changeset/85139
Log:
coroutine: coroutine_error + coroutine_errc
Added:
   trunk/boost/coroutine/exceptions.hpp   (contents, props changed)
   trunk/libs/coroutine/src/exceptions.cpp   (contents, props changed)
Text files modified: 
   trunk/boost/coroutine/all.hpp                             |     1                                         
   trunk/boost/coroutine/exceptions.hpp                      |   105 ++++++++++++++++++++++++++++++++++++++++
   trunk/boost/coroutine/v1/detail/coroutine_base_resume.hpp |     2                                         
   trunk/boost/coroutine/v1/detail/coroutine_object.hpp      |     2                                         
   trunk/boost/coroutine/v2/coroutine.hpp                    |    68 ++++++++++++++++++++-----               
   trunk/boost/coroutine/v2/detail/pull_coroutine_base.hpp   |    13 +++-                                    
   trunk/boost/coroutine/v2/detail/pull_coroutine_object.hpp |     2                                         
   trunk/boost/coroutine/v2/detail/push_coroutine_base.hpp   |     2                                         
   trunk/boost/coroutine/v2/detail/push_coroutine_object.hpp |     2                                         
   trunk/libs/coroutine/build/Jamfile.v2                     |     1                                         
   trunk/libs/coroutine/example/cpp03/echo.cpp               |    20 +++---                                  
   trunk/libs/coroutine/example/cpp03/fibonacci.cpp          |    12 ++--                                    
   trunk/libs/coroutine/example/cpp03/parallel.cpp           |    18 +++---                                  
   trunk/libs/coroutine/example/cpp03/power.cpp              |    14 ++--                                    
   trunk/libs/coroutine/example/cpp03/segmented_stack.cpp    |     8 +-                                      
   trunk/libs/coroutine/example/cpp03/unwind.cpp             |     8 +-                                      
   trunk/libs/coroutine/example/cpp11/fibonacci.cpp          |    12 ++--                                    
   trunk/libs/coroutine/src/exceptions.cpp                   |    36 +++++++++++++                           
   trunk/libs/coroutine/test/Jamfile.v2                      |     1                                         
   trunk/libs/coroutine/test/test_coroutine.cpp              |    23 ++++++++                                
   20 files changed, 279 insertions(+), 71 deletions(-)
Modified: trunk/boost/coroutine/all.hpp
==============================================================================
--- trunk/boost/coroutine/all.hpp	Tue Jul 23 13:40:15 2013	(r85138)
+++ trunk/boost/coroutine/all.hpp	2013-07-23 15:49:38 EDT (Tue, 23 Jul 2013)	(r85139)
@@ -9,6 +9,7 @@
 
 #include <boost/coroutine/attributes.hpp>
 #include <boost/coroutine/coroutine.hpp>
+#include <boost/coroutine/exceptions.hpp>
 #include <boost/coroutine/flags.hpp>
 #include <boost/coroutine/stack_allocator.hpp>
 
Added: trunk/boost/coroutine/exceptions.hpp
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ trunk/boost/coroutine/exceptions.hpp	2013-07-23 15:49:38 EDT (Tue, 23 Jul 2013)	(r85139)
@@ -0,0 +1,105 @@
+
+//          Copyright Oliver Kowalke 2009.
+// 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)
+
+#ifndef BOOST_COROUTINES_EXCEPTIONS_H
+#define BOOST_COROUTINES_EXCEPTIONS_H
+
+#include <stdexcept>
+#include <string>
+
+#include <boost/config.hpp>
+#include <boost/detail/scoped_enum_emulation.hpp>
+#include <boost/system/error_code.hpp>
+#include <boost/system/system_error.hpp>
+#include <boost/type_traits/integral_constant.hpp>
+
+#include <boost/coroutine/detail/config.hpp>
+
+#ifdef BOOST_HAS_ABI_HEADERS
+#  include BOOST_ABI_PREFIX
+#endif
+
+namespace boost {
+namespace coroutines {
+namespace detail {
+
+struct forced_unwind {};
+
+}
+
+BOOST_SCOPED_ENUM_DECLARE_BEGIN(coroutine_errc)
+{
+  no_data = 1
+}
+BOOST_SCOPED_ENUM_DECLARE_END(coroutine_errc)
+
+BOOST_COROUTINES_DECL system::error_category const& coroutine_category() BOOST_NOEXCEPT;
+
+}
+
+namespace system {
+
+template<>
+struct is_error_code_enum< coroutines::coroutine_errc > : public true_type
+{};
+
+#ifdef BOOST_NO_CXX11_SCOPED_ENUMS
+template<>
+struct is_error_code_enum< coroutines::coroutine_errc::enum_type > : public true_type
+{};
+#endif
+
+inline
+error_code make_error_code( coroutines::coroutine_errc e) //BOOST_NOEXCEPT
+{
+    return error_code( underlying_cast< int >( e), coroutines::coroutine_category() );
+}
+
+inline
+error_condition make_error_condition( coroutines::coroutine_errc e) //BOOST_NOEXCEPT
+{
+    return error_condition( underlying_cast< int >( e), coroutines::coroutine_category() );
+}
+
+}
+
+namespace coroutines {
+
+class coroutine_error : public std::logic_error
+{
+private:
+    system::error_code  ec_;
+
+public:
+    coroutine_error( system::error_code ec) :
+        logic_error( ec.message() ),
+        ec_( ec)
+    {}
+
+    system::error_code const& code() const BOOST_NOEXCEPT
+    { return ec_; }
+
+    const char* what() const throw()
+    { return code().message().c_str(); }
+};
+
+class invalid_result : public coroutine_error
+{
+public:
+    invalid_result() :
+        coroutine_error(
+            system::make_error_code(
+                coroutine_errc::no_data) )
+    {}
+};
+
+}}
+
+#ifdef BOOST_HAS_ABI_HEADERS
+#  include BOOST_ABI_SUFFIX
+#endif
+
+#endif // BOOST_COROUTINES_EXCEPTIONS_H
Modified: trunk/boost/coroutine/v1/detail/coroutine_base_resume.hpp
==============================================================================
--- trunk/boost/coroutine/v1/detail/coroutine_base_resume.hpp	Tue Jul 23 13:40:15 2013	(r85138)
+++ trunk/boost/coroutine/v1/detail/coroutine_base_resume.hpp	2013-07-23 15:49:38 EDT (Tue, 23 Jul 2013)	(r85139)
@@ -22,7 +22,7 @@
 
 #include <boost/coroutine/detail/config.hpp>
 #include <boost/coroutine/detail/coroutine_context.hpp>
-#include <boost/coroutine/detail/exceptions.hpp>
+#include <boost/coroutine/exceptions.hpp>
 #include <boost/coroutine/detail/holder.hpp>
 #include <boost/coroutine/v1/detail/arg.hpp>
 
Modified: trunk/boost/coroutine/v1/detail/coroutine_object.hpp
==============================================================================
--- trunk/boost/coroutine/v1/detail/coroutine_object.hpp	Tue Jul 23 13:40:15 2013	(r85138)
+++ trunk/boost/coroutine/v1/detail/coroutine_object.hpp	2013-07-23 15:49:38 EDT (Tue, 23 Jul 2013)	(r85139)
@@ -21,7 +21,7 @@
 
 #include <boost/coroutine/attributes.hpp>
 #include <boost/coroutine/detail/config.hpp>
-#include <boost/coroutine/detail/exceptions.hpp>
+#include <boost/coroutine/exceptions.hpp>
 #include <boost/coroutine/detail/flags.hpp>
 #include <boost/coroutine/detail/holder.hpp>
 #include <boost/coroutine/detail/param.hpp>
Modified: trunk/boost/coroutine/v2/coroutine.hpp
==============================================================================
--- trunk/boost/coroutine/v2/coroutine.hpp	Tue Jul 23 13:40:15 2013	(r85138)
+++ trunk/boost/coroutine/v2/coroutine.hpp	2013-07-23 15:49:38 EDT (Tue, 23 Jul 2013)	(r85139)
@@ -16,6 +16,7 @@
 #include <boost/move/move.hpp>
 #include <boost/optional.hpp>
 #include <boost/range.hpp>
+#include <boost/throw_exception.hpp>
 #include <boost/type_traits/decay.hpp>
 #include <boost/type_traits/function_traits.hpp>
 #include <boost/type_traits/is_convertible.hpp>
@@ -26,6 +27,7 @@
 #include <boost/coroutine/detail/config.hpp>
 #include <boost/coroutine/detail/coroutine_context.hpp>
 #include <boost/coroutine/detail/param.hpp>
+#include <boost/coroutine/exceptions.hpp>
 #include <boost/coroutine/stack_allocator.hpp>
 #include <boost/coroutine/v2/detail/pull_coroutine_base.hpp>
 #include <boost/coroutine/v2/detail/pull_coroutine_caller.hpp>
@@ -1079,7 +1081,7 @@
 
     R get() const
     {
-        BOOST_ASSERT( has_result() );
+        BOOST_ASSERT( ! empty() );
 
         return impl_->get();
     }
@@ -1156,17 +1158,27 @@
         }
 
         reference_t operator*() const
-        { return const_cast< optional< R > & >( val_).get(); }
+        {
+            if ( ! val_)
+                boost::throw_exception(
+                    invalid_result() );
+            return const_cast< optional< R > & >( val_).get();
+        }
 
         pointer_t operator->() const
-        { return const_cast< optional< R > & >( val_).get_ptr(); }
+        {
+            if ( ! val_)
+                boost::throw_exception(
+                    invalid_result() );
+            return const_cast< optional< R > & >( val_).get_ptr();
+        }
     };
 
     class const_iterator : public std::iterator< std::input_iterator_tag, const typename remove_reference< R >::type >
     {
     private:
         pull_coroutine< R > *   c_;
-        optional< R >      val_;
+        optional< R >           val_;
 
         void fetch_()
         {
@@ -1234,10 +1246,20 @@
         }
 
         reference_t operator*() const
-        { return val_.get(); }
+        {
+            if ( ! val_)
+                boost::throw_exception(
+                    invalid_result() );
+            return val_.get();
+        }
 
         pointer_t operator->() const
-        { return val_.get_ptr(); }
+        {
+            if ( ! val_)
+                boost::throw_exception(
+                    invalid_result() );
+            return val_.get_ptr();
+        }
     };
 };
 
@@ -1579,11 +1601,7 @@
     }
 
     R & get() const
-    {
-        BOOST_ASSERT( has_result() );
-
-        return impl_->get();
-    }
+    { return impl_->get(); }
 
     class iterator : public std::iterator< std::input_iterator_tag, R >
     {
@@ -1657,10 +1675,20 @@
         }
 
         reference_t operator*() const
-        { return const_cast< optional< R & > & >( val_).get(); }
+        {
+            if ( ! val_)
+                boost::throw_exception(
+                    invalid_result() );
+            return const_cast< optional< R & > & >( val_).get();
+        }
 
         pointer_t operator->() const
-        { return const_cast< optional< R & > & >( val_).get_ptr(); }
+        {
+            if ( ! val_)
+                boost::throw_exception(
+                    invalid_result() );
+            return const_cast< optional< R & > & >( val_).get_ptr();
+        }
     };
 
     class const_iterator : public std::iterator< std::input_iterator_tag, R >
@@ -1735,10 +1763,20 @@
         }
 
         reference_t operator*() const
-        { return val_.get(); }
+        {
+            if ( ! val_)
+                boost::throw_exception(
+                    invalid_result() );
+            return val_.get();
+        }
 
         pointer_t operator->() const
-        { return val_.get_ptr(); }
+        {
+            if ( ! val_)
+                boost::throw_exception(
+                    invalid_result() );
+            return val_.get_ptr();
+        }
     };
 };
 
Modified: trunk/boost/coroutine/v2/detail/pull_coroutine_base.hpp
==============================================================================
--- trunk/boost/coroutine/v2/detail/pull_coroutine_base.hpp	Tue Jul 23 13:40:15 2013	(r85138)
+++ trunk/boost/coroutine/v2/detail/pull_coroutine_base.hpp	2013-07-23 15:49:38 EDT (Tue, 23 Jul 2013)	(r85139)
@@ -14,6 +14,7 @@
 #include <boost/intrusive_ptr.hpp>
 #include <boost/optional.hpp>
 #include <boost/type_traits/function_traits.hpp>
+#include <boost/throw_exception.hpp>
 #include <boost/utility.hpp>
 
 #include <boost/coroutine/detail/config.hpp>
@@ -21,7 +22,7 @@
 #include <boost/coroutine/detail/flags.hpp>
 #include <boost/coroutine/detail/holder.hpp>
 #include <boost/coroutine/detail/param.hpp>
-#include <boost/coroutine/detail/exceptions.hpp>
+#include <boost/coroutine/exceptions.hpp>
 
 #ifdef BOOST_HAS_ABI_HEADERS
 #  include BOOST_ABI_PREFIX
@@ -130,8 +131,9 @@
 
     R get() const
     {
-        BOOST_ASSERT( has_result() );
-   
+        if ( ! has_result() )
+            boost::throw_exception(
+                invalid_result() );
         return result_.get(); 
     }
 };
@@ -232,8 +234,9 @@
 
     R & get() const
     {
-        BOOST_ASSERT( has_result() );
-
+        if ( ! has_result() )
+            boost::throw_exception(
+                invalid_result() );
         return * result_.get();
     }
 };
Modified: trunk/boost/coroutine/v2/detail/pull_coroutine_object.hpp
==============================================================================
--- trunk/boost/coroutine/v2/detail/pull_coroutine_object.hpp	Tue Jul 23 13:40:15 2013	(r85138)
+++ trunk/boost/coroutine/v2/detail/pull_coroutine_object.hpp	2013-07-23 15:49:38 EDT (Tue, 23 Jul 2013)	(r85139)
@@ -21,7 +21,7 @@
 
 #include <boost/coroutine/attributes.hpp>
 #include <boost/coroutine/detail/config.hpp>
-#include <boost/coroutine/detail/exceptions.hpp>
+#include <boost/coroutine/exceptions.hpp>
 #include <boost/coroutine/detail/flags.hpp>
 #include <boost/coroutine/detail/holder.hpp>
 #include <boost/coroutine/detail/param.hpp>
Modified: trunk/boost/coroutine/v2/detail/push_coroutine_base.hpp
==============================================================================
--- trunk/boost/coroutine/v2/detail/push_coroutine_base.hpp	Tue Jul 23 13:40:15 2013	(r85138)
+++ trunk/boost/coroutine/v2/detail/push_coroutine_base.hpp	2013-07-23 15:49:38 EDT (Tue, 23 Jul 2013)	(r85139)
@@ -17,7 +17,7 @@
 
 #include <boost/coroutine/detail/config.hpp>
 #include <boost/coroutine/detail/coroutine_context.hpp>
-#include <boost/coroutine/detail/exceptions.hpp>
+#include <boost/coroutine/exceptions.hpp>
 #include <boost/coroutine/detail/flags.hpp>
 
 #ifdef BOOST_HAS_ABI_HEADERS
Modified: trunk/boost/coroutine/v2/detail/push_coroutine_object.hpp
==============================================================================
--- trunk/boost/coroutine/v2/detail/push_coroutine_object.hpp	Tue Jul 23 13:40:15 2013	(r85138)
+++ trunk/boost/coroutine/v2/detail/push_coroutine_object.hpp	2013-07-23 15:49:38 EDT (Tue, 23 Jul 2013)	(r85139)
@@ -21,7 +21,7 @@
 
 #include <boost/coroutine/attributes.hpp>
 #include <boost/coroutine/detail/config.hpp>
-#include <boost/coroutine/detail/exceptions.hpp>
+#include <boost/coroutine/exceptions.hpp>
 #include <boost/coroutine/detail/flags.hpp>
 #include <boost/coroutine/detail/holder.hpp>
 #include <boost/coroutine/detail/param.hpp>
Modified: trunk/libs/coroutine/build/Jamfile.v2
==============================================================================
--- trunk/libs/coroutine/build/Jamfile.v2	Tue Jul 23 13:40:15 2013	(r85138)
+++ trunk/libs/coroutine/build/Jamfile.v2	2013-07-23 15:49:38 EDT (Tue, 23 Jul 2013)	(r85139)
@@ -45,6 +45,7 @@
 lib boost_coroutine
     : allocator_sources
       detail/coroutine_context.cpp
+      exceptions.cpp
     : <link>shared:<library>../../context/build//boost_context
     ;
 
Modified: trunk/libs/coroutine/example/cpp03/echo.cpp
==============================================================================
--- trunk/libs/coroutine/example/cpp03/echo.cpp	Tue Jul 23 13:40:15 2013	(r85138)
+++ trunk/libs/coroutine/example/cpp03/echo.cpp	2013-07-23 15:49:38 EDT (Tue, 23 Jul 2013)	(r85139)
@@ -14,31 +14,31 @@
 typedef boost::coroutines::coroutine< void >::pull_type pull_coro_t;
 typedef boost::coroutines::coroutine< void >::push_type push_coro_t;
 
-void echo( pull_coro_t & c, int i)
+void echo( pull_coro_t & source, int i)
 {
     std::cout << i;
-    c();
+    source();
 }
 
-void runit( push_coro_t & ca)
+void runit( push_coro_t & sink1)
 {
     std::cout << "started! ";
     for ( int i = 0; i < 10; ++i)
     {
-        push_coro_t c( boost::bind( echo, _1, i) );
-        while ( c)
-            c();
-        ca();
+        push_coro_t sink2( boost::bind( echo, _1, i) );
+        while ( sink2)
+            sink2();
+        sink1();
     }
 }
 
 int main( int argc, char * argv[])
 {
     {
-        pull_coro_t c( runit);
-        while ( c) {
+        pull_coro_t source( runit);
+        while ( source) {
             std::cout << "-";
-            c();
+            source();
         }
     }
 
Modified: trunk/libs/coroutine/example/cpp03/fibonacci.cpp
==============================================================================
--- trunk/libs/coroutine/example/cpp03/fibonacci.cpp	Tue Jul 23 13:40:15 2013	(r85138)
+++ trunk/libs/coroutine/example/cpp03/fibonacci.cpp	2013-07-23 15:49:38 EDT (Tue, 23 Jul 2013)	(r85139)
@@ -11,26 +11,26 @@
 #include <boost/coroutine/all.hpp>
 
 #ifdef BOOST_COROUTINES_UNIDIRECT
-void fibonacci( boost::coroutines::coroutine< int >::push_type & c)
+void fibonacci( boost::coroutines::coroutine< int >::push_type & sink)
 {
     int first = 1, second = 1;
-    c( first);     
-    c( second);     
+    sink( first);     
+    sink( second);     
     while ( true)
     {
         int third = first + second;
         first = second;
         second = third;
-        c( third);     
+        sink( third);     
     }
 }
 
 int main()
 {
-    boost::coroutines::coroutine< int >::pull_type c( fibonacci);
+    boost::coroutines::coroutine< int >::pull_type source( fibonacci);
     boost::range_iterator<
        boost::coroutines::coroutine< int >::pull_type
-    >::type   it( boost::begin( c) );
+    >::type   it( boost::begin( source) );
     for ( int i = 0; i < 10; ++i)
     {
         std::cout << * it <<  " ";
Modified: trunk/libs/coroutine/example/cpp03/parallel.cpp
==============================================================================
--- trunk/libs/coroutine/example/cpp03/parallel.cpp	Tue Jul 23 13:40:15 2013	(r85138)
+++ trunk/libs/coroutine/example/cpp03/parallel.cpp	2013-07-23 15:49:38 EDT (Tue, 23 Jul 2013)	(r85139)
@@ -11,22 +11,22 @@
 #include <boost/coroutine/all.hpp>
 
 #ifdef BOOST_COROUTINES_UNIDIRECT
-void first( boost::coroutines::coroutine< void >::push_type & c)
+void first( boost::coroutines::coroutine< void >::push_type & sink)
 {
     std::cout << "started first! ";
     for ( int i = 0; i < 10; ++i)
     {
-        c();
+        sink();
         std::cout << "a" << i;
     }
 }
 
-void second( boost::coroutines::coroutine< void >::push_type & c)
+void second( boost::coroutines::coroutine< void >::push_type & sink)
 {
     std::cout << "started second! ";
     for ( int i = 0; i < 10; ++i)
     {
-        c();
+        sink();
         std::cout << "b" << i;
     }
 }
@@ -34,12 +34,12 @@
 int main( int argc, char * argv[])
 {
     {
-        boost::coroutines::coroutine< void >::pull_type c1( boost::bind( first, _1) );
-        boost::coroutines::coroutine< void >::pull_type c2( boost::bind( second, _1) );
-        while ( c1 && c2) {
-            c1();
+        boost::coroutines::coroutine< void >::pull_type source1( boost::bind( first, _1) );
+        boost::coroutines::coroutine< void >::pull_type source2( boost::bind( second, _1) );
+        while ( source1 && source2) {
+            source1();
             std::cout << " ";
-            c2();
+            source2();
             std::cout << " ";
         }
     }
Modified: trunk/libs/coroutine/example/cpp03/power.cpp
==============================================================================
--- trunk/libs/coroutine/example/cpp03/power.cpp	Tue Jul 23 13:40:15 2013	(r85138)
+++ trunk/libs/coroutine/example/cpp03/power.cpp	2013-07-23 15:49:38 EDT (Tue, 23 Jul 2013)	(r85139)
@@ -13,14 +13,14 @@
 #include <boost/coroutine/all.hpp>
 
 #ifdef BOOST_COROUTINES_UNIDIRECT
-void power( boost::coroutines::coroutine< int >::push_type & c, int number, int exponent)
+void power( boost::coroutines::coroutine< int >::push_type & sink, int number, int exponent)
 {
     int counter = 0;
     int result = 1;
     while ( counter++ < exponent)
     {
             result = result * number;
-            c( result);
+            sink( result);
     }
 }
 
@@ -28,17 +28,17 @@
 {
     {
         std::cout << "using range functions" << std::endl;
-        boost::coroutines::coroutine< int >::pull_type c( boost::bind( power, _1, 2, 8) );
-        boost::coroutines::coroutine< int >::pull_type::iterator e( boost::end( c) );
-        for ( boost::coroutines::coroutine< int >::pull_type::iterator i( boost::begin( c) );
+        boost::coroutines::coroutine< int >::pull_type source( boost::bind( power, _1, 2, 8) );
+        boost::coroutines::coroutine< int >::pull_type::iterator e( boost::end( source) );
+        for ( boost::coroutines::coroutine< int >::pull_type::iterator i( boost::begin( source) );
               i != e; ++i)
             std::cout << * i <<  " ";
     }
 
     {
         std::cout << "\nusing BOOST_FOREACH" << std::endl;
-        boost::coroutines::coroutine< int >::pull_type c( boost::bind( power, _1, 2, 8) );
-        BOOST_FOREACH( int i, c)
+        boost::coroutines::coroutine< int >::pull_type source( boost::bind( power, _1, 2, 8) );
+        BOOST_FOREACH( int i, source)
         { std::cout << i <<  " "; }
     }
 
Modified: trunk/libs/coroutine/example/cpp03/segmented_stack.cpp
==============================================================================
--- trunk/libs/coroutine/example/cpp03/segmented_stack.cpp	Tue Jul 23 13:40:15 2013	(r85138)
+++ trunk/libs/coroutine/example/cpp03/segmented_stack.cpp	2013-07-23 15:49:38 EDT (Tue, 23 Jul 2013)	(r85139)
@@ -32,17 +32,17 @@
 }
 
 #ifdef BOOST_COROUTINES_UNIDIRECT
-void foo( boost::coroutines::coroutine< void >::pull_type & c)
+void foo( boost::coroutines::coroutine< void >::pull_type & source)
 {
     bar( count);
-    c();
+    source();
 }
 
 void thread_fn()
 {
     {
-        boost::coroutines::coroutine< void >::push_type c( foo);
-        c();
+        boost::coroutines::coroutine< void >::push_type sink( foo);
+        sink();
     }
 }
 #else
Modified: trunk/libs/coroutine/example/cpp03/unwind.cpp
==============================================================================
--- trunk/libs/coroutine/example/cpp03/unwind.cpp	Tue Jul 23 13:40:15 2013	(r85138)
+++ trunk/libs/coroutine/example/cpp03/unwind.cpp	2013-07-23 15:49:38 EDT (Tue, 23 Jul 2013)	(r85139)
@@ -17,24 +17,24 @@
     ~X() { std::cout << "~X()" << std::endl; }
 };
 
-void fn( boost::coroutines::coroutine< void >::push_type & c)
+void fn( boost::coroutines::coroutine< void >::push_type & sink)
 {
     X x;
     int i = 0;
     while ( true)
     {
         std::cout << "fn() : " << ++i << std::endl;
-        c();
+        sink();
     }
 }
 
 int main( int argc, char * argv[])
 {
     {
-        boost::coroutines::coroutine< void >::pull_type c( fn);
+        boost::coroutines::coroutine< void >::pull_type source( fn);
         for ( int k = 0; k < 3; ++k)
         {
-            c();
+            source();
         }
         std::cout << "destroying coroutine and unwinding stack" << std::endl;
     }
Modified: trunk/libs/coroutine/example/cpp11/fibonacci.cpp
==============================================================================
--- trunk/libs/coroutine/example/cpp11/fibonacci.cpp	Tue Jul 23 13:40:15 2013	(r85138)
+++ trunk/libs/coroutine/example/cpp11/fibonacci.cpp	2013-07-23 15:49:38 EDT (Tue, 23 Jul 2013)	(r85139)
@@ -12,21 +12,21 @@
 #ifdef BOOST_COROUTINES_UNIDIRECT
 int main()
 {
-    boost::coroutines::coroutine< int >::pull_type c(
-        [&]( boost::coroutines::coroutine< int >::push_type & c) {
+    boost::coroutines::coroutine< int >::pull_type source(
+        [&]( boost::coroutines::coroutine< int >::push_type & sink) {
             int first = 1, second = 1;
-            c( first);
-            c( second);
+            sink( first);
+            sink( second);
             for ( int i = 0; i < 8; ++i)
             {
                 int third = first + second;
                 first = second;
                 second = third;
-                c( third);
+                sink( third);
             }
         });
 
-    for ( auto i : c)
+    for ( auto i : source)
         std::cout << i <<  " ";
 
     std::cout << "\nDone" << std::endl;
Added: trunk/libs/coroutine/src/exceptions.cpp
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ trunk/libs/coroutine/src/exceptions.cpp	2013-07-23 15:49:38 EDT (Tue, 23 Jul 2013)	(r85139)
@@ -0,0 +1,36 @@
+
+//          Copyright Oliver Kowalke 2009.
+// 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)
+
+#include <boost/coroutine/exceptions.hpp>
+
+namespace boost {
+namespace coroutines {
+
+class coroutine_error_category : public system::error_category
+{
+public:
+    virtual const char* name() const BOOST_NOEXCEPT
+    { return "coroutine"; }
+
+    virtual std::string message( int ev) const
+    {
+        switch (BOOST_SCOPED_ENUM_NATIVE(coroutine_errc)(ev))
+        {
+        case coroutine_errc::no_data:
+            return std::string("Operation not permitted because coroutine "
+                          "has no valid result.");
+        }
+        return std::string("unspecified coroutine_errc value\n");
+    }
+};
+
+system::error_category const& coroutine_category() BOOST_NOEXCEPT
+{
+    static coroutines::coroutine_error_category cat;
+    return cat;
+}
+
+}}
Modified: trunk/libs/coroutine/test/Jamfile.v2
==============================================================================
--- trunk/libs/coroutine/test/Jamfile.v2	Tue Jul 23 13:40:15 2013	(r85138)
+++ trunk/libs/coroutine/test/Jamfile.v2	2013-07-23 15:49:38 EDT (Tue, 23 Jul 2013)	(r85139)
@@ -18,6 +18,7 @@
       <library>../../test/build//boost_unit_test_framework
       <library>/boost/context//boost_context
       <library>/boost/coroutine//boost_coroutine
+      <library>/boost/system//boost_system
       <toolset>gcc-4.7,<segmented-stacks>on:<cxxflags>-fsplit-stack
       <toolset>gcc-4.8,<segmented-stacks>on:<cxxflags>-fsplit-stack
       <link>static
Modified: trunk/libs/coroutine/test/test_coroutine.cpp
==============================================================================
--- trunk/libs/coroutine/test/test_coroutine.cpp	Tue Jul 23 13:40:15 2013	(r85138)
+++ trunk/libs/coroutine/test/test_coroutine.cpp	2013-07-23 15:49:38 EDT (Tue, 23 Jul 2013)	(r85139)
@@ -197,6 +197,9 @@
     { c( ptr); }
 }
 
+void f20( coro::coroutine< int >::push_type &)
+{}
+
 void test_move()
 {
     {
@@ -510,6 +513,24 @@
     BOOST_CHECK_EQUAL( ( int)3, vec[2] );
     BOOST_CHECK_EQUAL( ( int)4, vec[3] );
 }
+
+void test_invalid_result()
+{
+    bool catched = false;
+    coro::coroutine< int >::pull_type coro( f20);
+    BOOST_CHECK( ! coro);
+    try
+    {
+        int i = coro.get();
+    }
+    catch ( coro::invalid_result const& e)
+    {
+        boost::system::error_code ec = e.code();
+        BOOST_CHECK_EQUAL( coro::coroutine_errc::no_data, ec.value()); 
+        catched = true; 
+    }
+    BOOST_CHECK( catched);
+}
 #else
 typedef coro::coroutine< void() > coro_void_void;
 typedef coro::coroutine< int() > coro_int_void;
@@ -1039,6 +1060,8 @@
 #ifndef BOOST_COROUTINES_UNIDIRECT
     test->add( BOOST_TEST_CASE( & test_pre) );
     test->add( BOOST_TEST_CASE( & test_post) );
+#else
+    test->add( BOOST_TEST_CASE( & test_invalid_result) );
 #endif
     test->add( BOOST_TEST_CASE( & test_ref) );
     test->add( BOOST_TEST_CASE( & test_const_ref) );