add boost coroutine with patches; patch funciton_template.

Fri, 04 Mar 2011 12:51:59 -0800

author
Andrew A. de Laix <alain@lindenlab.com>
date
Fri, 04 Mar 2011 12:51:59 -0800
changeset 16
f52596dba2a6
parent 15
97cc37b6e95e
child 17
6ceb57105738

add boost coroutine with patches; patch funciton_template.

boost_1_45_0/boost/coroutine/coroutine.hpp file | annotate | diff | revisions
boost_1_45_0/boost/coroutine/coroutine.hpp.orig file | annotate | diff | revisions
boost_1_45_0/boost/coroutine/detail/arg_max.hpp file | annotate | diff | revisions
boost_1_45_0/boost/coroutine/detail/argument_packer.hpp file | annotate | diff | revisions
boost_1_45_0/boost/coroutine/detail/argument_unpacker.hpp file | annotate | diff | revisions
boost_1_45_0/boost/coroutine/detail/call_impl.hpp file | annotate | diff | revisions
boost_1_45_0/boost/coroutine/detail/context_base.hpp file | annotate | diff | revisions
boost_1_45_0/boost/coroutine/detail/context_linux.hpp file | annotate | diff | revisions
boost_1_45_0/boost/coroutine/detail/context_posix.hpp file | annotate | diff | revisions
boost_1_45_0/boost/coroutine/detail/context_windows.hpp file | annotate | diff | revisions
boost_1_45_0/boost/coroutine/detail/coroutine_accessor.hpp file | annotate | diff | revisions
boost_1_45_0/boost/coroutine/detail/coroutine_impl.hpp file | annotate | diff | revisions
boost_1_45_0/boost/coroutine/detail/coroutine_traits.hpp file | annotate | diff | revisions
boost_1_45_0/boost/coroutine/detail/default_context_impl.hpp file | annotate | diff | revisions
boost_1_45_0/boost/coroutine/detail/fix_result.hpp file | annotate | diff | revisions
boost_1_45_0/boost/coroutine/detail/future_impl.hpp file | annotate | diff | revisions
boost_1_45_0/boost/coroutine/detail/has_swap.hpp file | annotate | diff | revisions
boost_1_45_0/boost/coroutine/detail/index.hpp file | annotate | diff | revisions
boost_1_45_0/boost/coroutine/detail/is_callable.hpp file | annotate | diff | revisions
boost_1_45_0/boost/coroutine/detail/make_tuple_traits.hpp file | annotate | diff | revisions
boost_1_45_0/boost/coroutine/detail/noreturn.hpp file | annotate | diff | revisions
boost_1_45_0/boost/coroutine/detail/posix_utility.hpp file | annotate | diff | revisions
boost_1_45_0/boost/coroutine/detail/self.hpp file | annotate | diff | revisions
boost_1_45_0/boost/coroutine/detail/signal.hpp file | annotate | diff | revisions
boost_1_45_0/boost/coroutine/detail/signature.hpp file | annotate | diff | revisions
boost_1_45_0/boost/coroutine/detail/swap_context.hpp file | annotate | diff | revisions
boost_1_45_0/boost/coroutine/detail/wait_impl.hpp file | annotate | diff | revisions
boost_1_45_0/boost/coroutine/detail/yield_result_type.hpp file | annotate | diff | revisions
boost_1_45_0/boost/coroutine/exception.hpp file | annotate | diff | revisions
boost_1_45_0/boost/coroutine/future.hpp file | annotate | diff | revisions
boost_1_45_0/boost/coroutine/generator.hpp file | annotate | diff | revisions
boost_1_45_0/boost/coroutine/move.hpp file | annotate | diff | revisions
boost_1_45_0/boost/coroutine/shared_coroutine.hpp file | annotate | diff | revisions
boost_1_45_0/boost/coroutine/tuple_traits.hpp file | annotate | diff | revisions
boost_1_45_0/boost/function/function_template.hpp file | annotate | diff | revisions
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/boost_1_45_0/boost/coroutine/coroutine.hpp	Fri Mar 04 12:51:59 2011 -0800
     1.3 @@ -0,0 +1,302 @@
     1.4 +//  Copyright (c) 2006, Giovanni P. Deretta
     1.5 +//
     1.6 +//  This code may be used under either of the following two licences:
     1.7 +//
     1.8 +//  Permission is hereby granted, free of charge, to any person obtaining a copy 
     1.9 +//  of this software and associated documentation files (the "Software"), to deal 
    1.10 +//  in the Software without restriction, including without limitation the rights 
    1.11 +//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 
    1.12 +//  copies of the Software, and to permit persons to whom the Software is 
    1.13 +//  furnished to do so, subject to the following conditions:
    1.14 +//
    1.15 +//  The above copyright notice and this permission notice shall be included in 
    1.16 +//  all copies or substantial portions of the Software.
    1.17 +//
    1.18 +//  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
    1.19 +//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
    1.20 +//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
    1.21 +//  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
    1.22 +//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
    1.23 +//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 
    1.24 +//  THE SOFTWARE. OF SUCH DAMAGE.
    1.25 +//
    1.26 +//  Or:
    1.27 +//
    1.28 +//  Distributed under the Boost Software License, Version 1.0.
    1.29 +//  (See accompanying file LICENSE_1_0.txt or copy at
    1.30 +//  http://www.boost.org/LICENSE_1_0.txt)
    1.31 +
    1.32 +#ifndef BOOST_COROUTINE_COROUTINE_HPP_20060512
    1.33 +#define BOOST_COROUTINE_COROUTINE_HPP_20060512
    1.34 +// On Linux systems, use native swapcontext() et al. rather than
    1.35 +// Boost.Coroutine homebrew assembler
    1.36 +#define BOOST_COROUTINE_NO_ASM
    1.37 +// default_context_impl.hpp must be first for weird Apple bug
    1.38 +#include <boost/coroutine/detail/default_context_impl.hpp>
    1.39 +#include <cstddef>
    1.40 +#include <boost/preprocessor/repetition.hpp>
    1.41 +#include <boost/tuple/tuple.hpp>
    1.42 +#include <boost/utility/enable_if.hpp>
    1.43 +#include <boost/mpl/vector.hpp>
    1.44 +#include <boost/type_traits.hpp>
    1.45 +#include <boost/call_traits.hpp>
    1.46 +#include <boost/coroutine/detail/arg_max.hpp>
    1.47 +#include <boost/coroutine/detail/coroutine_impl.hpp>
    1.48 +#include <boost/coroutine/detail/is_callable.hpp>
    1.49 +#include <boost/coroutine/detail/argument_packer.hpp>
    1.50 +#include <boost/coroutine/detail/argument_unpacker.hpp>
    1.51 +#include <boost/coroutine/detail/signature.hpp>
    1.52 +#include <boost/coroutine/detail/index.hpp>
    1.53 +#include <boost/coroutine/detail/coroutine_traits.hpp>
    1.54 +#include <boost/coroutine/detail/coroutine_accessor.hpp>
    1.55 +#include <boost/coroutine/move.hpp>
    1.56 +#include <boost/coroutine/detail/fix_result.hpp>
    1.57 +#include <boost/coroutine/detail/self.hpp>
    1.58 +
    1.59 +namespace boost { namespace coroutines {
    1.60 +  namespace detail {
    1.61 +    template<typename T>
    1.62 +    struct optional_result_type : 
    1.63 +      boost::mpl::if_<boost::is_same<T, void>,
    1.64 +		      void,
    1.65 +		      boost::optional<T> > { };
    1.66 +
    1.67 +    template<typename T>
    1.68 +    BOOST_DEDUCED_TYPENAME
    1.69 +    boost::enable_if<boost::is_same<T, void> >::type
    1.70 +    optional_result() {}
    1.71 +
    1.72 +    template<typename T>
    1.73 +    BOOST_DEDUCED_TYPENAME
    1.74 +    boost::disable_if<boost::is_same<T, void>,
    1.75 +		      BOOST_DEDUCED_TYPENAME
    1.76 +		      optional_result_type<T>::type
    1.77 +		      >::type
    1.78 +    optional_result() {
    1.79 +      return BOOST_DEDUCED_TYPENAME
    1.80 +	optional_result_type<T>::type();
    1.81 +    }
    1.82 +  }
    1.83 +
    1.84 +  template<typename Signature, typename Context>
    1.85 +  class coroutine;
    1.86 +
    1.87 +  template<typename T>
    1.88 +  struct is_coroutine : boost::mpl::false_{};
    1.89 +  
    1.90 +  template<typename Sig, typename Con>
    1.91 +  struct is_coroutine<coroutine<Sig, Con> > : boost::mpl::true_{};
    1.92 +
    1.93 +  template<typename Signature, 
    1.94 +	   typename ContextImpl = detail::default_context_impl>
    1.95 +  class coroutine : public movable<coroutine<Signature, ContextImpl> > {
    1.96 +  public:
    1.97 +    typedef coroutine<Signature, ContextImpl> type;
    1.98 +    typedef ContextImpl context_impl;
    1.99 +    typedef Signature signature_type;
   1.100 +    friend struct detail::coroutine_accessor;
   1.101 +
   1.102 +    typedef BOOST_DEDUCED_TYPENAME 
   1.103 +    detail::coroutine_traits<signature_type>
   1.104 +    ::result_type result_type;
   1.105 +
   1.106 +    typedef BOOST_DEDUCED_TYPENAME 
   1.107 +    detail::coroutine_traits<signature_type>
   1.108 +    ::result_slot_type result_slot_type;
   1.109 +
   1.110 +    typedef BOOST_DEDUCED_TYPENAME 
   1.111 +    detail::coroutine_traits<signature_type>
   1.112 +    ::yield_result_type yield_result_type;
   1.113 +
   1.114 +    typedef BOOST_DEDUCED_TYPENAME 
   1.115 +    detail::coroutine_traits<signature_type>
   1.116 +    ::result_slot_traits result_slot_traits;
   1.117 +
   1.118 +    typedef BOOST_DEDUCED_TYPENAME 
   1.119 +    detail::coroutine_traits<signature_type>
   1.120 +    ::arg_slot_type arg_slot_type;
   1.121 +
   1.122 +    typedef BOOST_DEDUCED_TYPENAME 
   1.123 +    detail::coroutine_traits<signature_type>
   1.124 +    ::arg_slot_traits arg_slot_traits;
   1.125 +        
   1.126 +    typedef detail::coroutine_impl<type, context_impl> impl_type;
   1.127 +    typedef BOOST_DEDUCED_TYPENAME  impl_type::pointer impl_ptr;  
   1.128 +   
   1.129 +    typedef detail::coroutine_self<type> self;
   1.130 +    coroutine() : m_pimpl(0) {}
   1.131 +
   1.132 +    template<typename Functor>
   1.133 +    coroutine (Functor f, 
   1.134 +	       std::ptrdiff_t stack_size = detail::default_stack_size,
   1.135 +	       BOOST_DEDUCED_TYPENAME boost::enable_if<
   1.136 +	       boost::mpl::and_<
   1.137 +	       detail::is_callable<Functor>, 
   1.138 +	       boost::mpl::not_<is_coroutine<Functor> >
   1.139 +	       > >
   1.140 +	       ::type * = 0
   1.141 +	       ) :
   1.142 +      m_pimpl(impl_type::create(f, stack_size)) {}
   1.143 + 
   1.144 +    coroutine(move_from<coroutine> src) 
   1.145 +      : m_pimpl(src->m_pimpl) {
   1.146 +      src->m_pimpl = 0;
   1.147 +    }
   1.148 +
   1.149 +    coroutine& operator=(move_from<coroutine> src) {
   1.150 +      coroutine(src).swap(*this);
   1.151 +      return *this;
   1.152 +    }
   1.153 +
   1.154 +    coroutine& swap(coroutine& rhs) {
   1.155 +      std::swap(m_pimpl, rhs.m_pimpl);
   1.156 +      return *this;
   1.157 +    }
   1.158 +
   1.159 +    friend
   1.160 +    void swap(coroutine& lhs, coroutine& rhs) {
   1.161 +      lhs.swap(rhs);
   1.162 +    }
   1.163 +
   1.164 +#   define BOOST_COROUTINE_generate_argument_n_type(z, n, traits_type) \
   1.165 +    typedef BOOST_DEDUCED_TYPENAME traits_type ::template at<n>::type  \
   1.166 +    BOOST_PP_CAT(BOOST_PP_CAT(arg, n), _type);                         \
   1.167 +    /**/
   1.168 +
   1.169 +    BOOST_PP_REPEAT(BOOST_COROUTINE_ARG_MAX,
   1.170 +		    BOOST_COROUTINE_generate_argument_n_type,
   1.171 +		    arg_slot_traits);
   1.172 +
   1.173 +    static const int arity = arg_slot_traits::length;
   1.174 +
   1.175 +    struct yield_traits {
   1.176 +      BOOST_PP_REPEAT(BOOST_COROUTINE_ARG_MAX,
   1.177 +		      BOOST_COROUTINE_generate_argument_n_type,
   1.178 +		      result_slot_traits);
   1.179 +      static const int arity = result_slot_traits::length;
   1.180 +    };
   1.181 +
   1.182 +#   undef BOOST_COROUTINE_generate_argument_n_type
   1.183 +   
   1.184 +#   define BOOST_COROUTINE_param_with_default(z, n, type_prefix)    \
   1.185 +    BOOST_DEDUCED_TYPENAME call_traits                              \
   1.186 +    <BOOST_PP_CAT(BOOST_PP_CAT(type_prefix, n), _type)>::param_type \
   1.187 +    BOOST_PP_CAT(arg, n) =                                          \
   1.188 +    BOOST_PP_CAT(BOOST_PP_CAT(type_prefix, n), _type)()             \
   1.189 +    /**/
   1.190 +
   1.191 +    result_type operator()
   1.192 +      (BOOST_PP_ENUM
   1.193 +       (BOOST_COROUTINE_ARG_MAX,
   1.194 +	BOOST_COROUTINE_param_with_default,
   1.195 +	arg)) {
   1.196 +      return call_impl
   1.197 +	(arg_slot_type(BOOST_PP_ENUM_PARAMS
   1.198 +	  (BOOST_COROUTINE_ARG_MAX, 
   1.199 +	   arg)));
   1.200 +    }
   1.201 +
   1.202 +    BOOST_DEDUCED_TYPENAME
   1.203 +    detail::optional_result_type<result_type>::type 
   1.204 +    operator()
   1.205 +      (const std::nothrow_t&
   1.206 +       BOOST_PP_ENUM_TRAILING
   1.207 +       (BOOST_COROUTINE_ARG_MAX,
   1.208 +	BOOST_COROUTINE_param_with_default,
   1.209 +	arg)) {
   1.210 +      return call_impl_nothrow
   1.211 +	(arg_slot_type(BOOST_PP_ENUM_PARAMS
   1.212 +	  (BOOST_COROUTINE_ARG_MAX, 
   1.213 +	   arg)));
   1.214 +    }
   1.215 +
   1.216 +#   undef BOOST_COROUTINE_param_typedef
   1.217 +#   undef BOOST_COROUTINE_param_with_default
   1.218 +
   1.219 +    typedef void(coroutine::*bool_type)();
   1.220 +    operator bool_type() const {
   1.221 +      return good()? &coroutine::bool_type_f: 0;
   1.222 +    }
   1.223 +
   1.224 +    bool operator==(const coroutine& rhs) {
   1.225 +      return m_pimpl == rhs.m_pimpl;
   1.226 +    }
   1.227 +
   1.228 +    void exit() {
   1.229 +      BOOST_ASSERT(m_pimpl);
   1.230 +      m_pimpl->exit();
   1.231 +    }
   1.232 +
   1.233 +    bool waiting() const {
   1.234 +      BOOST_ASSERT(m_pimpl);
   1.235 +      return m_pimpl->waiting();
   1.236 +    }
   1.237 +
   1.238 +    bool pending() const {
   1.239 +      BOOST_ASSERT(m_pimpl);
   1.240 +      return m_pimpl->pending();
   1.241 +    }
   1.242 +
   1.243 +    bool exited() const {
   1.244 +      BOOST_ASSERT(m_pimpl);
   1.245 +      return m_pimpl->exited();
   1.246 +    }
   1.247 +
   1.248 +    bool empty() const {
   1.249 +      return m_pimpl == 0;
   1.250 +    }
   1.251 +  protected:
   1.252 +
   1.253 +    // The second parameter is used to avoid calling this constructor
   1.254 +    // by mistake from other member funcitons (specifically operator=).
   1.255 +    coroutine(impl_type * pimpl, detail::init_from_impl_tag) :
   1.256 +      m_pimpl(pimpl) {}
   1.257 +
   1.258 +    void bool_type_f() {}
   1.259 +
   1.260 +    bool good() const  {
   1.261 +      return !empty() && !exited() && !waiting();
   1.262 +    }
   1.263 +
   1.264 +    result_type call_impl(arg_slot_type args) {
   1.265 +      BOOST_ASSERT(m_pimpl);
   1.266 +      m_pimpl->bind_args(&args);
   1.267 +      BOOST_DEDUCED_TYPENAME impl_type::local_result_slot_ptr ptr(m_pimpl);
   1.268 +      m_pimpl->invoke();
   1.269 +
   1.270 +      return detail::fix_result<result_slot_traits>(*m_pimpl->result());
   1.271 +    }
   1.272 +
   1.273 +    BOOST_DEDUCED_TYPENAME
   1.274 +    detail::optional_result_type<result_type>::type 
   1.275 +    call_impl_nothrow(arg_slot_type args) {
   1.276 +      BOOST_ASSERT(m_pimpl);
   1.277 +      m_pimpl->bind_args(&args);
   1.278 +      BOOST_DEDUCED_TYPENAME impl_type::local_result_slot_ptr ptr(m_pimpl);
   1.279 +      if(!m_pimpl->wake_up())
   1.280 +	return detail::optional_result<result_type>();
   1.281 +
   1.282 +      return detail::fix_result<result_slot_traits>(*m_pimpl->result());
   1.283 +    }
   1.284 +
   1.285 +    impl_ptr m_pimpl;
   1.286 +
   1.287 +    void acquire() {
   1.288 +      m_pimpl->acquire();
   1.289 +    }
   1.290 +
   1.291 +    void release() {
   1.292 +      m_pimpl->release();
   1.293 +    }
   1.294 +
   1.295 +    std::size_t
   1.296 +    count() const {
   1.297 +      return m_pimpl->count();
   1.298 +    }
   1.299 +
   1.300 +    impl_ptr get_impl() {
   1.301 +      return m_pimpl;
   1.302 +    }
   1.303 +  };
   1.304 +} }
   1.305 +#endif
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/boost_1_45_0/boost/coroutine/coroutine.hpp.orig	Fri Mar 04 12:51:59 2011 -0800
     2.3 @@ -0,0 +1,304 @@
     2.4 +//  Copyright (c) 2006, Giovanni P. Deretta
     2.5 +//
     2.6 +//  This code may be used under either of the following two licences:
     2.7 +//
     2.8 +//  Permission is hereby granted, free of charge, to any person obtaining a copy 
     2.9 +//  of this software and associated documentation files (the "Software"), to deal 
    2.10 +//  in the Software without restriction, including without limitation the rights 
    2.11 +//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 
    2.12 +//  copies of the Software, and to permit persons to whom the Software is 
    2.13 +//  furnished to do so, subject to the following conditions:
    2.14 +//
    2.15 +//  The above copyright notice and this permission notice shall be included in 
    2.16 +//  all copies or substantial portions of the Software.
    2.17 +//
    2.18 +//  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
    2.19 +//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
    2.20 +//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
    2.21 +//  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
    2.22 +//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
    2.23 +//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 
    2.24 +//  THE SOFTWARE. OF SUCH DAMAGE.
    2.25 +//
    2.26 +//  Or:
    2.27 +//
    2.28 +//  Distributed under the Boost Software License, Version 1.0.
    2.29 +//  (See accompanying file LICENSE_1_0.txt or copy at
    2.30 +//  http://www.boost.org/LICENSE_1_0.txt)
    2.31 +
    2.32 +#ifndef BOOST_COROUTINE_COROUTINE_HPP_20060512
    2.33 +#define BOOST_COROUTINE_COROUTINE_HPP_20060512
    2.34 +// On Linux systems, use native swapcontext() et al. rather than
    2.35 +// Boost.Coroutine homebrew assembler
    2.36 +#define BOOST_COROUTINE_NO_ASM
    2.37 +// default_context_impl.hpp must be first for weird Apple bug
    2.38 +#include <boost/coroutine/detail/default_context_impl.hpp>
    2.39 +#include <cstddef>
    2.40 +#include <boost/preprocessor/repetition.hpp>
    2.41 +#include <boost/tuple/tuple.hpp>
    2.42 +#include <boost/utility/enable_if.hpp>
    2.43 +#include <boost/mpl/vector.hpp>
    2.44 +#include <boost/type_traits.hpp>
    2.45 +#include <boost/call_traits.hpp>
    2.46 +#include <boost/coroutine/detail/arg_max.hpp>
    2.47 +#include <boost/coroutine/detail/coroutine_impl.hpp>
    2.48 +#include <boost/coroutine/detail/is_callable.hpp>
    2.49 +#include <boost/coroutine/detail/argument_packer.hpp>
    2.50 +#include <boost/coroutine/detail/argument_unpacker.hpp>
    2.51 +#include <boost/coroutine/detail/signature.hpp>
    2.52 +#include <boost/coroutine/detail/index.hpp>
    2.53 +#include <boost/coroutine/detail/coroutine_traits.hpp>
    2.54 +#include <boost/coroutine/detail/coroutine_accessor.hpp>
    2.55 +#include <boost/coroutine/move.hpp>
    2.56 +#include <boost/coroutine/detail/fix_result.hpp>
    2.57 +#include <boost/coroutine/detail/self.hpp>
    2.58 +
    2.59 +namespace boost { namespace coroutines {
    2.60 +  namespace detail {
    2.61 +    template<typename T>
    2.62 +    struct optional_result_type : 
    2.63 +      boost::mpl::if_<boost::is_same<T, void>,
    2.64 +		      void,
    2.65 +		      boost::optional<T> > { };
    2.66 +
    2.67 +    template<typename T>
    2.68 +    BOOST_DEDUCED_TYPENAME
    2.69 +    boost::enable_if<boost::is_same<T, void> >::type
    2.70 +    optional_result() {}
    2.71 +
    2.72 +    template<typename T>
    2.73 +    BOOST_DEDUCED_TYPENAME
    2.74 +    boost::disable_if<boost::is_same<T, void>,
    2.75 +		      BOOST_DEDUCED_TYPENAME
    2.76 +		      optional_result_type<T>::type
    2.77 +		      >::type
    2.78 +    optional_result() {
    2.79 +      return BOOST_DEDUCED_TYPENAME
    2.80 +	optional_result_type<T>::type();
    2.81 +    }
    2.82 +  }
    2.83 +
    2.84 +  template<typename Signature, typename Context>
    2.85 +  class coroutine;
    2.86 +
    2.87 +  template<typename T>
    2.88 +  struct is_coroutine : boost::mpl::false_{};
    2.89 +  
    2.90 +  template<typename Sig, typename Con>
    2.91 +  struct is_coroutine<coroutine<Sig, Con> > : boost::mpl::true_{};
    2.92 +
    2.93 +  template<typename Signature, 
    2.94 +	   typename ContextImpl = detail::default_context_impl>
    2.95 +  class coroutine : public movable<coroutine<Signature, ContextImpl> > {
    2.96 +  public:
    2.97 +    typedef coroutine<Signature, ContextImpl> type;
    2.98 +    typedef ContextImpl context_impl;
    2.99 +    typedef Signature signature_type;
   2.100 +    friend struct detail::coroutine_accessor;
   2.101 +
   2.102 +    typedef BOOST_DEDUCED_TYPENAME 
   2.103 +    detail::coroutine_traits<signature_type>
   2.104 +    ::result_type result_type;
   2.105 +
   2.106 +    typedef BOOST_DEDUCED_TYPENAME 
   2.107 +    detail::coroutine_traits<signature_type>
   2.108 +    ::result_slot_type result_slot_type;
   2.109 +
   2.110 +    typedef BOOST_DEDUCED_TYPENAME 
   2.111 +    detail::coroutine_traits<signature_type>
   2.112 +    ::yield_result_type yield_result_type;
   2.113 +
   2.114 +    typedef BOOST_DEDUCED_TYPENAME 
   2.115 +    detail::coroutine_traits<signature_type>
   2.116 +    ::result_slot_traits result_slot_traits;
   2.117 +
   2.118 +    typedef BOOST_DEDUCED_TYPENAME 
   2.119 +    detail::coroutine_traits<signature_type>
   2.120 +    ::arg_slot_type arg_slot_type;
   2.121 +
   2.122 +    typedef BOOST_DEDUCED_TYPENAME 
   2.123 +    detail::coroutine_traits<signature_type>
   2.124 +    ::arg_slot_traits arg_slot_traits;
   2.125 +        
   2.126 +    typedef detail::coroutine_impl<type, context_impl> impl_type;
   2.127 +    typedef BOOST_DEDUCED_TYPENAME  impl_type::pointer impl_ptr;  
   2.128 +   
   2.129 +    typedef detail::coroutine_self<type> self;
   2.130 +    coroutine() : m_pimpl(0) {}
   2.131 +
   2.132 +    template<typename Functor>
   2.133 +    coroutine (Functor f, 
   2.134 +	       std::ptrdiff_t stack_size = detail::default_stack_size,
   2.135 +	       BOOST_DEDUCED_TYPENAME boost::enable_if<
   2.136 +	       boost::mpl::and_<
   2.137 +	       detail::is_callable<Functor>, 
   2.138 +	       boost::mpl::not_<is_coroutine<Functor> >
   2.139 +	       > >
   2.140 +	       ::type * = 0
   2.141 +	       ) :
   2.142 +      m_pimpl(impl_type::create(f, stack_size)) {}
   2.143 + 
   2.144 +    coroutine(move_from<coroutine> src) 
   2.145 +      : m_pimpl(src->m_pimpl) {
   2.146 +      src->m_pimpl = 0;
   2.147 +    }
   2.148 +
   2.149 +    coroutine& operator=(move_from<coroutine> src) {
   2.150 +      coroutine(src).swap(*this);
   2.151 +      return *this;
   2.152 +    }
   2.153 +
   2.154 +    coroutine& swap(coroutine& rhs) {
   2.155 +      std::swap(m_pimpl, rhs.m_pimpl);
   2.156 +      return *this;
   2.157 +    }
   2.158 +
   2.159 +    friend
   2.160 +    void swap(coroutine& lhs, coroutine& rhs) {
   2.161 +      lhs.swap(rhs);
   2.162 +    }
   2.163 +
   2.164 +#   define BOOST_COROUTINE_generate_argument_n_type(z, n, traits_type) \
   2.165 +    typedef BOOST_DEDUCED_TYPENAME traits_type ::template at<n>::type  \
   2.166 +    BOOST_PP_CAT(BOOST_PP_CAT(arg, n), _type);                         \
   2.167 +    /**/
   2.168 +
   2.169 +    BOOST_PP_REPEAT(BOOST_COROUTINE_ARG_MAX,
   2.170 +		    BOOST_COROUTINE_generate_argument_n_type,
   2.171 +		    arg_slot_traits);
   2.172 +
   2.173 +    static const int arity = arg_slot_traits::length;
   2.174 +
   2.175 +    struct yield_traits {
   2.176 +      BOOST_PP_REPEAT(BOOST_COROUTINE_ARG_MAX,
   2.177 +		      BOOST_COROUTINE_generate_argument_n_type,
   2.178 +		      result_slot_traits);
   2.179 +      static const int arity = result_slot_traits::length;
   2.180 +    };
   2.181 +
   2.182 +#   undef BOOST_COROUTINE_generate_argument_n_type
   2.183 +   
   2.184 +#   define BOOST_COROUTINE_param_with_default(z, n, type_prefix)    \
   2.185 +    BOOST_DEDUCED_TYPENAME call_traits                              \
   2.186 +    <BOOST_PP_CAT(BOOST_PP_CAT(type_prefix, n), _type)>::param_type \
   2.187 +    BOOST_PP_CAT(arg, n) =                                          \
   2.188 +    BOOST_PP_CAT(BOOST_PP_CAT(type_prefix, n), _type)()             \
   2.189 +    /**/
   2.190 +
   2.191 +    result_type operator()
   2.192 +      (BOOST_PP_ENUM
   2.193 +       (BOOST_COROUTINE_ARG_MAX,
   2.194 +	BOOST_COROUTINE_param_with_default,
   2.195 +	arg)) {
   2.196 +      return call_impl
   2.197 +	(arg_slot_type(BOOST_PP_ENUM_PARAMS
   2.198 +	  (BOOST_COROUTINE_ARG_MAX, 
   2.199 +	   arg)));
   2.200 +    }
   2.201 +
   2.202 +    BOOST_DEDUCED_TYPENAME
   2.203 +    detail::optional_result_type<result_type>::type 
   2.204 +    operator()
   2.205 +      (const std::nothrow_t&
   2.206 +       BOOST_PP_ENUM_TRAILING
   2.207 +       (BOOST_COROUTINE_ARG_MAX,
   2.208 +	BOOST_COROUTINE_param_with_default,
   2.209 +	arg)) {
   2.210 +      return call_impl_nothrow
   2.211 +	(arg_slot_type(BOOST_PP_ENUM_PARAMS
   2.212 +	  (BOOST_COROUTINE_ARG_MAX, 
   2.213 +	   arg)));
   2.214 +    }
   2.215 +
   2.216 +#   undef BOOST_COROUTINE_param_typedef
   2.217 +#   undef BOOST_COROUTINE_param_with_default
   2.218 +
   2.219 +    typedef void(coroutine::*bool_type)();
   2.220 +    operator bool_type() const {
   2.221 +      return good()? &coroutine::bool_type_f: 0;
   2.222 +    }
   2.223 +
   2.224 +    bool operator==(const coroutine& rhs) {
   2.225 +      return m_pimpl == rhs.m_pimpl;
   2.226 +    }
   2.227 +
   2.228 +    void exit() {
   2.229 +      BOOST_ASSERT(m_pimpl);
   2.230 +      m_pimpl->exit();
   2.231 +    }
   2.232 +
   2.233 +    bool waiting() const {
   2.234 +      BOOST_ASSERT(m_pimpl);
   2.235 +      return m_pimpl->waiting();
   2.236 +    }
   2.237 +
   2.238 +    bool pending() const {
   2.239 +      BOOST_ASSERT(m_pimpl);
   2.240 +      return m_pimpl->pending();
   2.241 +    }
   2.242 +
   2.243 +    bool exited() const {
   2.244 +      BOOST_ASSERT(m_pimpl);
   2.245 +      return m_pimpl->exited();
   2.246 +    }
   2.247 +
   2.248 +    bool empty() const {
   2.249 +      return m_pimpl == 0;
   2.250 +    }
   2.251 +  protected:
   2.252 +
   2.253 +    // The second parameter is used to avoid calling this constructor
   2.254 +    // by mistake from other member funcitons (specifically operator=).
   2.255 +    coroutine(impl_type * pimpl, detail::init_from_impl_tag) :
   2.256 +      m_pimpl(pimpl) {}
   2.257 +
   2.258 +    void bool_type_f() {}
   2.259 +
   2.260 +    bool good() const  {
   2.261 +      return !empty() && !exited() && !waiting();
   2.262 +    }
   2.263 +
   2.264 +    result_type call_impl(arg_slot_type args) {
   2.265 +      BOOST_ASSERT(m_pimpl);
   2.266 +      m_pimpl->bind_args(&args);
   2.267 +      result_slot_type * ptr;
   2.268 +      m_pimpl->bind_result_pointer(&ptr);
   2.269 +      m_pimpl->invoke();
   2.270 +
   2.271 +      return detail::fix_result<result_slot_traits>(*m_pimpl->result());
   2.272 +    }
   2.273 +
   2.274 +    BOOST_DEDUCED_TYPENAME
   2.275 +    detail::optional_result_type<result_type>::type 
   2.276 +    call_impl_nothrow(arg_slot_type args) {
   2.277 +      BOOST_ASSERT(m_pimpl);
   2.278 +      m_pimpl->bind_args(&args);
   2.279 +      result_slot_type * ptr;
   2.280 +      m_pimpl->bind_result_pointer(&ptr);
   2.281 +      if(!m_pimpl->wake_up())
   2.282 +	return detail::optional_result<result_type>();
   2.283 +
   2.284 +      return detail::fix_result<result_slot_traits>(*m_pimpl->result());
   2.285 +    }
   2.286 +
   2.287 +    impl_ptr m_pimpl;
   2.288 +
   2.289 +    void acquire() {
   2.290 +      m_pimpl->acquire();
   2.291 +    }
   2.292 +
   2.293 +    void release() {
   2.294 +      m_pimpl->release();
   2.295 +    }
   2.296 +
   2.297 +    std::size_t
   2.298 +    count() const {
   2.299 +      return m_pimpl->count();
   2.300 +    }
   2.301 +
   2.302 +    impl_ptr get_impl() {
   2.303 +      return m_pimpl;
   2.304 +    }
   2.305 +  };
   2.306 +} }
   2.307 +#endif
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/boost_1_45_0/boost/coroutine/detail/arg_max.hpp	Fri Mar 04 12:51:59 2011 -0800
     3.3 @@ -0,0 +1,34 @@
     3.4 +//  Copyright (c) 2006, Giovanni P. Deretta
     3.5 +//
     3.6 +//  This code may be used under either of the following two licences:
     3.7 +//
     3.8 +//  Permission is hereby granted, free of charge, to any person obtaining a copy 
     3.9 +//  of this software and associated documentation files (the "Software"), to deal 
    3.10 +//  in the Software without restriction, including without limitation the rights 
    3.11 +//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 
    3.12 +//  copies of the Software, and to permit persons to whom the Software is 
    3.13 +//  furnished to do so, subject to the following conditions:
    3.14 +//
    3.15 +//  The above copyright notice and this permission notice shall be included in 
    3.16 +//  all copies or substantial portions of the Software.
    3.17 +//
    3.18 +//  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
    3.19 +//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
    3.20 +//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
    3.21 +//  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
    3.22 +//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
    3.23 +//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 
    3.24 +//  THE SOFTWARE. OF SUCH DAMAGE.
    3.25 +//
    3.26 +//  Or:
    3.27 +//
    3.28 +//  Distributed under the Boost Software License, Version 1.0.
    3.29 +//  (See accompanying file LICENSE_1_0.txt or copy at
    3.30 +//  http://www.boost.org/LICENSE_1_0.txt)
    3.31 +
    3.32 +#ifndef BOOST_COROUTINE_DETAIL_ARG_MAX_HPP_20060728
    3.33 +#  define BOOST_COROUTINE_DETAIL_ARG_MAX_HPP_20060728
    3.34 +#  ifndef BOOST_COROUTINE_ARG_MAX
    3.35 +#    define BOOST_COROUTINE_ARG_MAX 10
    3.36 +#  endif
    3.37 +#endif
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/boost_1_45_0/boost/coroutine/detail/argument_packer.hpp	Fri Mar 04 12:51:59 2011 -0800
     4.3 @@ -0,0 +1,70 @@
     4.4 +//  Copyright (c) 2006, Giovanni P. Deretta
     4.5 +//
     4.6 +//  This code may be used under either of the following two licences:
     4.7 +//
     4.8 +//  Permission is hereby granted, free of charge, to any person obtaining a copy 
     4.9 +//  of this software and associated documentation files (the "Software"), to deal 
    4.10 +//  in the Software without restriction, including without limitation the rights 
    4.11 +//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 
    4.12 +//  copies of the Software, and to permit persons to whom the Software is 
    4.13 +//  furnished to do so, subject to the following conditions:
    4.14 +//
    4.15 +//  The above copyright notice and this permission notice shall be included in 
    4.16 +//  all copies or substantial portions of the Software.
    4.17 +//
    4.18 +//  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
    4.19 +//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
    4.20 +//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
    4.21 +//  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
    4.22 +//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
    4.23 +//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 
    4.24 +//  THE SOFTWARE. OF SUCH DAMAGE.
    4.25 +//
    4.26 +//  Or:
    4.27 +//
    4.28 +//  Distributed under the Boost Software License, Version 1.0.
    4.29 +//  (See accompanying file LICENSE_1_0.txt or copy at
    4.30 +//  http://www.boost.org/LICENSE_1_0.txt)
    4.31 +
    4.32 +#ifndef BOOST_COROUTINE_ARGUMENT_PACKER_HPP_20060601
    4.33 +#define BOOST_COROUTINE_ARGUMENT_PACKER_HPP_20060601
    4.34 +#include <boost/preprocessor/control/if.hpp>
    4.35 +#include <boost/preprocessor/punctuation/comma_if.hpp>
    4.36 +#include <boost/preprocessor/repetition.hpp>
    4.37 +#include <boost/preprocessor/tuple/eat.hpp>
    4.38 +
    4.39 +namespace boost { namespace coroutines { namespace detail {
    4.40 +#define BOOST_COROUTINE_DETAIL_TEMPLATE_PARAMETERS(n)  \
    4.41 +  template<BOOST_PP_ENUM_PARAMS(n, typename T)> \
    4.42 +/**/
    4.43 +
    4.44 +#define BOOST_COROUTINE_ARGUMENT_PACKER(z, n, parm_tuple)        \
    4.45 +  BOOST_PP_IF(n,                                                 \
    4.46 +	      BOOST_COROUTINE_DETAIL_TEMPLATE_PARAMETERS ,              \
    4.47 +	      BOOST_PP_TUPLE_EAT(1) )(n)                         \
    4.48 +  BOOST_PP_TUPLE_ELEM(3, 0, parm_tuple)                          \
    4.49 +    (BOOST_PP_ENUM_BINARY_PARAMS(n, T, arg)) {                   \
    4.50 +    typedef BOOST_PP_TUPLE_ELEM(3, 2, parm_tuple) parm_type;     \
    4.51 +    return BOOST_PP_TUPLE_ELEM(3, 1, parm_tuple)                 \
    4.52 +                             (parm_type                          \
    4.53 +			      (BOOST_PP_ENUM_PARAMS(n, arg)));   \
    4.54 +  }                                                              \
    4.55 +/**/
    4.56 +
    4.57 +
    4.58 +#define BOOST_COROUTINE_ARGUMENT_PACKER_EX(z, n, parm_tuple)     \
    4.59 +  template<typename Arg                                          \
    4.60 +    BOOST_PP_COMMA_IF(n)                                         \
    4.61 +    BOOST_PP_ENUM_PARAMS(n, typename T)>                         \
    4.62 +  BOOST_PP_TUPLE_ELEM(3, 0, parm_tuple)                          \
    4.63 +  (Arg arg                                                       \
    4.64 +   BOOST_PP_COMMA_IF(n)                                          \
    4.65 +   BOOST_PP_ENUM_BINARY_PARAMS(n, T, arg)) {                     \
    4.66 +    typedef BOOST_PP_TUPLE_ELEM(3, 2, parm_tuple) parm_type;     \
    4.67 +    return BOOST_PP_TUPLE_ELEM(3, 1, parm_tuple)( arg, parm_type \
    4.68 +     (BOOST_PP_ENUM_PARAMS(n, arg)));                            \
    4.69 +  }                                                              \
    4.70 +/**/
    4.71 +
    4.72 +} } }
    4.73 +#endif
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/boost_1_45_0/boost/coroutine/detail/argument_unpacker.hpp	Fri Mar 04 12:51:59 2011 -0800
     5.3 @@ -0,0 +1,134 @@
     5.4 +//  Copyright (c) 2006, Giovanni P. Deretta
     5.5 +//
     5.6 +//  This code may be used under either of the following two licences:
     5.7 +//
     5.8 +//  Permission is hereby granted, free of charge, to any person obtaining a copy 
     5.9 +//  of this software and associated documentation files (the "Software"), to deal 
    5.10 +//  in the Software without restriction, including without limitation the rights 
    5.11 +//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 
    5.12 +//  copies of the Software, and to permit persons to whom the Software is 
    5.13 +//  furnished to do so, subject to the following conditions:
    5.14 +//
    5.15 +//  The above copyright notice and this permission notice shall be included in 
    5.16 +//  all copies or substantial portions of the Software.
    5.17 +//
    5.18 +//  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
    5.19 +//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
    5.20 +//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
    5.21 +//  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
    5.22 +//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
    5.23 +//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 
    5.24 +//  THE SOFTWARE. OF SUCH DAMAGE.
    5.25 +//
    5.26 +//  Or:
    5.27 +//
    5.28 +//  Distributed under the Boost Software License, Version 1.0.
    5.29 +//  (See accompanying file LICENSE_1_0.txt or copy at
    5.30 +//  http://www.boost.org/LICENSE_1_0.txt)
    5.31 +
    5.32 +#ifndef BOOST_COROUTINE_ARGUMENT_UNPACKER_HPP_20060601
    5.33 +#define BOOST_COROUTINE_ARGUMENT_UNPACKER_HPP_20060601
    5.34 +#include <boost/preprocessor/control/if.hpp>
    5.35 +#include <boost/preprocessor/repetition.hpp>
    5.36 +#include <boost/utility/result_of.hpp>
    5.37 +#include <boost/coroutine/detail/index.hpp>
    5.38 +#include <boost/coroutine/detail/arg_max.hpp>
    5.39 +
    5.40 +namespace boost { namespace coroutines { namespace detail {
    5.41 +  template<typename Traits, int Len>
    5.42 +  struct unpacker_n;
    5.43 +
    5.44 +  template<typename Traits, int Len>
    5.45 +  struct unpacker_ex_n;
    5.46 +
    5.47 +
    5.48 +#define BOOST_COROUTINE_ARGUMENT_UNPACKER(z, len, unused)              \
    5.49 +    template<typename Traits>                                          \
    5.50 +    struct unpacker_n<Traits, len> {                                   \
    5.51 +        template<typename Functor, typename Tuple>                     \
    5.52 +      struct result {/*for result_of compatibility*/                   \
    5.53 +	  typedef typename  boost::result_of                           \
    5.54 +             <Functor(BOOST_PP_ENUM_BINARY_PARAMS                      \
    5.55 +		      (len, typename Traits::template at<index_ , >    \
    5.56 +		       ::type BOOST_PP_INTERCEPT))>::type type;        \
    5.57 +      };                                                               \
    5.58 +      template<typename Functor, typename Tuple>                       \
    5.59 +      typename result<Functor, Tuple>::type operator()                 \
    5.60 +       (Functor& f, Tuple& parms){                                     \
    5.61 +           using boost::get; /*tuples::get cannot be found via ADL*/   \
    5.62 +           return f(BOOST_PP_ENUM_BINARY_PARAMS                        \
    5.63 +		    (len,                                              \
    5.64 +		     get<index_, >                                     \
    5.65 +		     (parms) BOOST_PP_INTERCEPT));                     \
    5.66 +      }                                                                \
    5.67 +    };                                                                 \
    5.68 +/**/
    5.69 +    
    5.70 +#define BOOST_COROUTINE_ARGUMENT_UNPACKER_EX(z, len, unused)           \
    5.71 +    template<typename Traits>                                          \
    5.72 +    struct unpacker_ex_n<Traits, len >           {                     \
    5.73 +    template<typename Functor,                                         \
    5.74 +             typename First,                                           \
    5.75 +	     typename Tuple>                                           \
    5.76 +      struct result {                                                  \
    5.77 +	  typedef typename  boost::result_of                           \
    5.78 +             <Functor(First BOOST_PP_COMMA_IF(len)                     \
    5.79 +		      BOOST_PP_ENUM_BINARY_PARAMS                      \
    5.80 +		      (len, typename Traits                            \
    5.81 +		       ::template at<index_ , >::type BOOST_PP_INTERCEPT))>     \
    5.82 +          ::type type;                                                 \
    5.83 +	};                                                             \
    5.84 +                                                                       \
    5.85 +      template<typename Functor,                                       \
    5.86 +               typename First,                                         \
    5.87 +	       typename Tuple>                                         \
    5.88 +      typename result<Functor, First, Tuple>::type                     \
    5.89 +      operator()(Functor& f, First& arg0, Tuple& parms){                \
    5.90 +           using boost::get; /*tuples::get cannot be found via ADL*/  \
    5.91 +           return f(arg0                                               \
    5.92 +		    BOOST_PP_COMMA_IF(len)                             \
    5.93 +		    BOOST_PP_ENUM_BINARY_PARAMS                        \
    5.94 +		    (len,                                              \
    5.95 +		     get<index_, >                                     \
    5.96 +		     (parms) BOOST_PP_INTERCEPT) );                    \
    5.97 +      }                                                                \
    5.98 +    };                                                                 \
    5.99 +/**/
   5.100 +
   5.101 +  BOOST_PP_REPEAT(BOOST_COROUTINE_ARG_MAX, 
   5.102 +		  BOOST_COROUTINE_ARGUMENT_UNPACKER, ~);
   5.103 +  BOOST_PP_REPEAT(BOOST_COROUTINE_ARG_MAX, 
   5.104 +		  BOOST_COROUTINE_ARGUMENT_UNPACKER_EX, ~);
   5.105 +
   5.106 +  // Somehow VCPP 8.0 chockes if the Trait for unpack[_ex]
   5.107 +  // is explicitly specified. We use an empty dispatch 
   5.108 +  // tag to let the compiler deduce it.
   5.109 +  template<typename Trait>
   5.110 +  struct trait_tag {};
   5.111 +
   5.112 +  /**
   5.113 +   * Inovoke function object @p f passing  all 
   5.114 +   * elements in tuple @p parms as distinct parameters.
   5.115 +   */
   5.116 +  template<typename Traits, typename Functor, typename Tuple>
   5.117 +  inline
   5.118 +  typename unpacker_n<Traits, Traits::length>
   5.119 +  ::template result<Functor, Tuple>::type
   5.120 +  unpack(Functor f, Tuple& parms, trait_tag<Traits>) {
   5.121 +    return unpacker_n<Traits, Traits::length>()(f, parms);
   5.122 +  }
   5.123 +
   5.124 +  /**
   5.125 +   * Inovke function object @p f passing argument @p arg0 and all 
   5.126 +   * elements in tuple @p parms as distinct parameters.
   5.127 +   */
   5.128 +  template<typename Traits, typename Functor, typename First, typename Tuple>
   5.129 +  inline
   5.130 +  typename unpacker_ex_n<Traits, Traits::length>::
   5.131 +  template result<Functor, First, Tuple>::type 
   5.132 +  unpack_ex(Functor f, First& arg0, Tuple& parms, trait_tag<Traits>) {
   5.133 +    return unpacker_ex_n<Traits, Traits::length>()
   5.134 +      (f, arg0, parms);
   5.135 +  }
   5.136 +} } }
   5.137 +#endif
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/boost_1_45_0/boost/coroutine/detail/call_impl.hpp	Fri Mar 04 12:51:59 2011 -0800
     6.3 @@ -0,0 +1,123 @@
     6.4 +//  Copyright (c) 2006, Giovanni P. Deretta
     6.5 +//
     6.6 +//  This code may be used under either of the following two licences:
     6.7 +//
     6.8 +//  Permission is hereby granted, free of charge, to any person obtaining a copy 
     6.9 +//  of this software and associated documentation files (the "Software"), to deal 
    6.10 +//  in the Software without restriction, including without limitation the rights 
    6.11 +//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 
    6.12 +//  copies of the Software, and to permit persons to whom the Software is 
    6.13 +//  furnished to do so, subject to the following conditions:
    6.14 +//
    6.15 +//  The above copyright notice and this permission notice shall be included in 
    6.16 +//  all copies or substantial portions of the Software.
    6.17 +//
    6.18 +//  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
    6.19 +//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
    6.20 +//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
    6.21 +//  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
    6.22 +//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
    6.23 +//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 
    6.24 +//  THE SOFTWARE. OF SUCH DAMAGE.
    6.25 +//
    6.26 +//  Or:
    6.27 +//
    6.28 +//  Distributed under the Boost Software License, Version 1.0.
    6.29 +//  (See accompanying file LICENSE_1_0.txt or copy at
    6.30 +//  http://www.boost.org/LICENSE_1_0.txt)
    6.31 +
    6.32 +#ifndef BOOST_COROUTINE_DETAIL_CALL_IMPL_HPP_20060728
    6.33 +#define BOOST_COROUTINE_DETAIL_CALL_IMPL_HPP_20060728
    6.34 +
    6.35 +#include <boost/preprocessor/repetition.hpp>
    6.36 +#include <boost/call_traits.hpp>
    6.37 +#include <boost/tuple/tuple.hpp>
    6.38 +#include <boost/bind.hpp>
    6.39 +#include <boost/coroutine/coroutine.hpp>
    6.40 +#include <boost/coroutine/detail/arg_max.hpp>
    6.41 +#include <boost/coroutine/detail/signal.hpp>
    6.42 +#include <boost/coroutine/detail/coroutine_accessor.hpp>
    6.43 +namespace boost { namespace coroutines { namespace detail {
    6.44 +
    6.45 +#define BOOST_COROUTINE_tuple_param_n(z, n, tuple)\
    6.46 +  BOOST_DEDUCED_TYPENAME                          \
    6.47 +  boost::tuples::element<n, tuple>::type          \
    6.48 +  BOOST_PP_CAT(arg, n)                            \
    6.49 + /**/
    6.50 +
    6.51 +  template<typename Future>                       
    6.52 +  class callback {
    6.53 +  public:
    6.54 +
    6.55 +    typedef void result_type;
    6.56 +    
    6.57 +    callback(Future& future) :
    6.58 +      m_future_pimpl(wait_gateway::get_impl(future)) {
    6.59 +      m_future_pimpl->mark_pending();
    6.60 +    }
    6.61 +    
    6.62 +    typedef BOOST_DEDUCED_TYPENAME                
    6.63 +    Future::tuple_type tuple_type;              
    6.64 +
    6.65 +    typedef BOOST_DEDUCED_TYPENAME                
    6.66 +    Future::tuple_traits_type tuple_traits_type;              
    6.67 +
    6.68 +    /*
    6.69 +     * By default a callback is one shot only.
    6.70 +     * By calling this method you can revive a 
    6.71 +     * callback for another shot.
    6.72 +     * You must guaranee that the future
    6.73 +     * is still alive.
    6.74 +     */
    6.75 +    void revive() {
    6.76 +      m_future_pimpl->mark_pending();
    6.77 +    }
    6.78 +
    6.79 +#define BOOST_COROUTINE_gen_argn_type(z, n, unused) \
    6.80 +    typedef BOOST_DEDUCED_TYPENAME                  \
    6.81 +    tuple_traits_type::                             \
    6.82 +    template at<n>::type                            \
    6.83 +    BOOST_PP_CAT(BOOST_PP_CAT(arg, n), _type);      \
    6.84 +/**/
    6.85 +
    6.86 +    BOOST_PP_REPEAT(BOOST_COROUTINE_ARG_MAX,
    6.87 +		    BOOST_COROUTINE_gen_argn_type,
    6.88 +		    ~);
    6.89 +      
    6.90 +#define BOOST_COROUTINE_param_with_default(z, n, type_prefix) \
    6.91 +    BOOST_DEDUCED_TYPENAME call_traits                   \
    6.92 +    <BOOST_PP_CAT(BOOST_PP_CAT(type_prefix, n), _type)>  \
    6.93 +    ::param_type                                         \
    6.94 +    BOOST_PP_CAT(arg, n) =                               \
    6.95 +    BOOST_PP_CAT(BOOST_PP_CAT(type_prefix, n), _type)()  \
    6.96 +/**/
    6.97 +    
    6.98 +    void operator() 
    6.99 +      (BOOST_PP_ENUM
   6.100 +       (BOOST_COROUTINE_ARG_MAX,
   6.101 +	BOOST_COROUTINE_param_with_default,
   6.102 +	arg)) {
   6.103 +      m_future_pimpl->assign(tuple_type
   6.104 +	(BOOST_PP_ENUM_PARAMS
   6.105 +	 (BOOST_COROUTINE_ARG_MAX, arg)));
   6.106 +    }
   6.107 +
   6.108 +  private:
   6.109 +    BOOST_DEDUCED_TYPENAME
   6.110 +    Future::impl_pointer
   6.111 +    m_future_pimpl;
   6.112 +  };  
   6.113 +  
   6.114 +#undef BOOST_COROUTINE_gen_future_assigner
   6.115 +#undef BOOST_COROUTINE_tuple_param_n
   6.116 +
   6.117 +  template<typename Future, typename Functor, typename CoroutineSelf>
   6.118 +  Future call_impl(Functor fun, const CoroutineSelf& coro_self) {
   6.119 +    Future future(coro_self);
   6.120 +    fun(callback<Future>(future));
   6.121 +    return future;
   6.122 +  }
   6.123 +
   6.124 +} } }
   6.125 +
   6.126 +#endif
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/boost_1_45_0/boost/coroutine/detail/context_base.hpp	Fri Mar 04 12:51:59 2011 -0800
     7.3 @@ -0,0 +1,416 @@
     7.4 +//  Copyright (c) 2006, Giovanni P. Deretta
     7.5 +//
     7.6 +//  This code may be used under either of the following two licences:
     7.7 +//
     7.8 +//  Permission is hereby granted, free of charge, to any person obtaining a copy 
     7.9 +//  of this software and associated documentation files (the "Software"), to deal 
    7.10 +//  in the Software without restriction, including without limitation the rights 
    7.11 +//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 
    7.12 +//  copies of the Software, and to permit persons to whom the Software is 
    7.13 +//  furnished to do so, subject to the following conditions:
    7.14 +//
    7.15 +//  The above copyright notice and this permission notice shall be included in 
    7.16 +//  all copies or substantial portions of the Software.
    7.17 +//
    7.18 +//  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
    7.19 +//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
    7.20 +//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
    7.21 +//  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
    7.22 +//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
    7.23 +//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 
    7.24 +//  THE SOFTWARE. OF SUCH DAMAGE.
    7.25 +//
    7.26 +//  Or:
    7.27 +//
    7.28 +//  Distributed under the Boost Software License, Version 1.0.
    7.29 +//  (See accompanying file LICENSE_1_0.txt or copy at
    7.30 +//  http://www.boost.org/LICENSE_1_0.txt)
    7.31 +
    7.32 +#ifndef BOOST_COROUTINE_CONTEXT_IMPL_HPP_20060810
    7.33 +#define BOOST_COROUTINE_CONTEXT_IMPL_HPP_20060810
    7.34 +/*
    7.35 + * Currently asio can, in some cases. call copy constructors and
    7.36 + * operator= from different threads, even if in the
    7.37 + * one-thread-per-service model. (i.e. from the resolver thread)
    7.38 + * This will be corrected in future versions, but for now
    7.39 + * we will play it safe and use an atomic count. The overhead shouldn't
    7.40 + * be big.
    7.41 + */
    7.42 +#define BOOST_COROUTINE_USE_ATOMIC_COUNT
    7.43 +
    7.44 +#ifdef BOOST_COROUTINE_USE_ATOMIC_COUNT
    7.45 +#  include <boost/detail/atomic_count.hpp>
    7.46 +#endif
    7.47 +#include <cstddef>
    7.48 +#include <algorithm> //for swap
    7.49 +#include <boost/coroutine/detail/swap_context.hpp> //for swap hints
    7.50 +#include <boost/intrusive_ptr.hpp>
    7.51 +#include <boost/coroutine/exception.hpp>
    7.52 +#include <boost/coroutine/detail/noreturn.hpp>
    7.53 +namespace boost { namespace coroutines { namespace detail {
    7.54 + 
    7.55 +  const std::ptrdiff_t default_stack_size = -1;
    7.56 +
    7.57 +  template<typename ContextImpl>
    7.58 +  class context_base : public ContextImpl {
    7.59 +  public:
    7.60 +
    7.61 +    typedef ContextImpl context_impl;
    7.62 +    typedef context_base<context_impl> type;
    7.63 +    typedef boost::intrusive_ptr<type> pointer;
    7.64 +    typedef void deleter_type(const type*);
    7.65 +    
    7.66 +    template<typename Derived>
    7.67 +	context_base(Derived& derived, 
    7.68 +		     std::ptrdiff_t stack_size) :
    7.69 +      context_impl(derived, stack_size),
    7.70 +      m_counter(0),
    7.71 +      m_deleter(&deleter<Derived>),
    7.72 +      m_state(ctx_ready), 
    7.73 +      m_exit_state(ctx_exit_not_requested),
    7.74 +      m_exit_status(ctx_not_exited),
    7.75 +      m_wait_counter(0),
    7.76 +      m_operation_counter(0),
    7.77 +      m_type_info(0) {}
    7.78 +    
    7.79 +    friend
    7.80 +    void intrusive_ptr_add_ref(type * ctx) {
    7.81 +      ctx->acquire();
    7.82 +    }
    7.83 +    
    7.84 +    friend
    7.85 +    void intrusive_ptr_release(type * ctx) {
    7.86 +      ctx->release();
    7.87 +    }
    7.88 +      
    7.89 +    bool unique() const {
    7.90 +      return count() == 1;
    7.91 +    }
    7.92 +
    7.93 +    std::size_t count() const {
    7.94 +      return m_counter;
    7.95 +    }
    7.96 +      
    7.97 +    void acquire() const {
    7.98 +      ++m_counter;
    7.99 +    }
   7.100 +      
   7.101 +    void release() const {
   7.102 +      BOOST_ASSERT(m_counter);
   7.103 +      if(--m_counter == 0) {
   7.104 +	m_deleter(this);
   7.105 +      }
   7.106 +    }
   7.107 +
   7.108 +    void count_down() throw() {
   7.109 +      BOOST_ASSERT(m_operation_counter) ;
   7.110 +      --m_operation_counter;
   7.111 +    }
   7.112 +
   7.113 +    void count_up() throw() {
   7.114 +      ++m_operation_counter;
   7.115 +    }
   7.116 +
   7.117 +    // return true if there are operations pending.
   7.118 +    int pending() const {
   7.119 +      return m_operation_counter;
   7.120 +    }
   7.121 +
   7.122 +    /*
   7.123 +     * A signal may occur only when a context is 
   7.124 +     * not running (is delivered sinchrononously).
   7.125 +     * This means that state MUST NOT be busy.
   7.126 +     * It may be ready or waiting.
   7.127 +     * returns 'ready()'.
   7.128 +     * Nothrow.
   7.129 +     */
   7.130 +    bool signal () throw() {
   7.131 +      BOOST_ASSERT(!running() && !exited());
   7.132 +      BOOST_ASSERT(m_wait_counter) ;
   7.133 +
   7.134 +      --m_wait_counter;
   7.135 +      if(!m_wait_counter && m_state == ctx_waiting)
   7.136 +	m_state = ctx_ready;      
   7.137 +      return ready();
   7.138 +    }
   7.139 +
   7.140 +    /*
   7.141 +     * Wake up a waiting context.
   7.142 +     * Similar to invoke(), but *does not
   7.143 +     * throw* if the coroutine exited normally
   7.144 +     * or entered the wait state.
   7.145 +     * It *does throw* if the coroutine
   7.146 +     * exited abnormally.
   7.147 +     * Return: false if invoke() would have thrown,
   7.148 +     *         true otherwise.
   7.149 +     * 
   7.150 +     */
   7.151 +    bool wake_up() {
   7.152 +      BOOST_ASSERT(ready());
   7.153 +      do_invoke();
   7.154 +      // TODO: could use a binary 'or' here to eliminate
   7.155 +      // shortcut evaluation (and a branch), but maybe the compiler is
   7.156 +      // smart enough to do it anyway as there are no side effects.
   7.157 +      if(m_exit_status || m_state == ctx_waiting) {
   7.158 +	if(m_state == ctx_waiting)
   7.159 +	  return false;
   7.160 +	if(m_exit_status == ctx_exited_return)
   7.161 +	  return true;
   7.162 +	if(m_exit_status == ctx_exited_abnormally) {
   7.163 +	std::type_info const * tinfo =0;
   7.164 +	std::swap(m_type_info, tinfo);
   7.165 +	throw abnormal_exit(tinfo?*tinfo: typeid(unknown_exception_tag));
   7.166 +	} else if(m_exit_status == ctx_exited_exit)
   7.167 +	  return false;
   7.168 +	else {
   7.169 +	  BOOST_ASSERT(0 && "unkonw exit status");
   7.170 +	}
   7.171 +      }
   7.172 +      return true;
   7.173 +    }
   7.174 +    /*
   7.175 +     * Returns true if the context is runnable.
   7.176 +     */
   7.177 +    bool ready() const {
   7.178 +      return m_state == ctx_ready;
   7.179 +    }
   7.180 +
   7.181 +    /*
   7.182 +     * Returns true if the context is in wait
   7.183 +     * state.
   7.184 +     */
   7.185 +    bool waiting() const {
   7.186 +      return m_state == ctx_waiting;
   7.187 +    }
   7.188 +
   7.189 +    bool running() const {
   7.190 +      return m_state == ctx_running;
   7.191 +    }
   7.192 +
   7.193 +    bool exited() const {
   7.194 +      return m_state == ctx_exited;
   7.195 +    }
   7.196 +
   7.197 +    // Resume coroutine.
   7.198 +    // Pre:  The coroutine must be ready.
   7.199 +    // Post: The coroutine relinquished control. It might be ready, waiting
   7.200 +    //       or exited.
   7.201 +    // Throws:- 'waiting' if the coroutine entered the wait state,
   7.202 +    //        - 'coroutine_exited' if the coroutine exited by an uncaught
   7.203 +    //          'exit_exception'.
   7.204 +    //        - 'abnormal_exit' if the coroutine was exited by another
   7.205 +    //          uncaught exception.
   7.206 +    // Note, it guarantees that the coroutine is resumed. Can throw only
   7.207 +    // on return.
   7.208 +    void invoke() {
   7.209 +      BOOST_ASSERT(ready());
   7.210 +      do_invoke();
   7.211 +      // TODO: could use a bynary or here to eliminate
   7.212 +      // shortcut evaluation (and a branch), but maybe the compiler is
   7.213 +      // smart enough to do it anyway as there are no side effects.
   7.214 +      if(m_exit_status || m_state == ctx_waiting) {
   7.215 +	if(m_state == ctx_waiting)
   7.216 +	  throw waiting();
   7.217 +	if(m_exit_status == ctx_exited_return)
   7.218 +	  return;
   7.219 +	if(m_exit_status == ctx_exited_abnormally) {
   7.220 +	std::type_info const * tinfo =0;
   7.221 +	std::swap(m_type_info, tinfo);
   7.222 +	throw abnormal_exit(tinfo?*tinfo: typeid(unknown_exception_tag));
   7.223 +	} else if(m_exit_status == ctx_exited_exit)
   7.224 +	  throw coroutine_exited();
   7.225 +      	else {
   7.226 +	  BOOST_ASSERT(0 && "unkonw exit status");
   7.227 +	}
   7.228 +      }
   7.229 +    }
   7.230 +
   7.231 +    // Put coroutine in ready state and relinquish control
   7.232 +    // to caller until resumed again.
   7.233 +    // Pre:  Coroutine is running.
   7.234 +    //       Exit not pending.
   7.235 +    //       Operations not pending.
   7.236 +    // Post: Coroutine is running.
   7.237 +    // Throws: exit_exception, if exit is pending *after* it has been
   7.238 +    //         resumed.
   7.239 +    void yield() {
   7.240 +      BOOST_ASSERT(m_exit_state < ctx_exit_signaled); //prevent infinite loops
   7.241 +      BOOST_ASSERT(running());
   7.242 +      BOOST_ASSERT(!pending());
   7.243 +
   7.244 +      m_state = ctx_ready;
   7.245 +      do_yield();
   7.246 +
   7.247 +      BOOST_ASSERT(running());
   7.248 +      check_exit_state();
   7.249 +    }
   7.250 +
   7.251 +    //
   7.252 +    // If n > 0, put the coroutine in the wait state
   7.253 +    // then relinquish control to caller. 
   7.254 +    // If n = 0 do nothing.
   7.255 +    // The coroutine will remain in the wait state until
   7.256 +    // is signaled 'n' times.
   7.257 +    // Pre:  0 <= n < pending()
   7.258 +    //       Coroutine is running.
   7.259 +    //       Exit not pending.
   7.260 +    // Post: Coroutine is running.
   7.261 +    //       The coroutine has been signaled 'n' times unless an exit
   7.262 +    //        has been signaled.
   7.263 +    // Throws: exit_exception.
   7.264 +    // FIXME: currently there is a BIG problem. A coroutine cannot
   7.265 +    // be exited as long as there are futures pending.
   7.266 +    // The exit_exception would cause the future to be destroyed and
   7.267 +    // an assertion to be generated. Removing an assertion is not a 
   7.268 +    // solution because we would leak the coroutine impl. The callback
   7.269 +    // bound to the future in fact hold a refrence to it. If the coroutine
   7.270 +    // is exited the callback cannot be called.
   7.271 +    void wait(int n) {
   7.272 +      BOOST_ASSERT(!(n<0));
   7.273 +      BOOST_ASSERT(m_exit_state < ctx_exit_signaled); //prevent infinite loop
   7.274 +      BOOST_ASSERT(running());
   7.275 +      BOOST_ASSERT(!(pending() < n));
   7.276 +
   7.277 +      if(n == 0) return;
   7.278 +      m_wait_counter = n;
   7.279 +
   7.280 +      m_state = ctx_waiting;
   7.281 +      do_yield();
   7.282 +
   7.283 +      BOOST_ASSERT(m_state == ctx_running);
   7.284 +      check_exit_state();
   7.285 +      BOOST_ASSERT(m_wait_counter == 0);
   7.286 +    }
   7.287 +
   7.288 +    // Throws: exit_exception.
   7.289 +    void yield_to(context_base& to) {
   7.290 +      BOOST_ASSERT(m_exit_state < ctx_exit_signaled); //prevent infinite loops
   7.291 +      BOOST_ASSERT(m_state == ctx_running);
   7.292 +      BOOST_ASSERT(to.ready());
   7.293 +      BOOST_ASSERT(!to.pending());
   7.294 +
   7.295 +      std::swap(m_caller, to.m_caller);
   7.296 +      std::swap(m_state, to.m_state);
   7.297 +      swap_context(*this, to, detail::yield_to_hint());
   7.298 +
   7.299 +      BOOST_ASSERT(m_state == ctx_running);
   7.300 +      check_exit_state();
   7.301 +    }
   7.302 +
   7.303 +    // Cause this coroutine to exit.
   7.304 +    // Can only be called on a ready coroutine.
   7.305 +    // Cannot be called if there are pending operations.
   7.306 +    // It follws that cannot be called from 'this'.
   7.307 +    // Nothrow.
   7.308 +    void exit() throw(){
   7.309 +      BOOST_ASSERT(!pending());
   7.310 +      BOOST_ASSERT(ready()) ;
   7.311 +      if(m_exit_state < ctx_exit_pending) 
   7.312 +	m_exit_state = ctx_exit_pending;	
   7.313 +      do_invoke();
   7.314 +      BOOST_ASSERT(exited()); //at this point the coroutine MUST have exited.
   7.315 +    }
   7.316 +
   7.317 +    // Always throw exit_exception.
   7.318 +    // Never returns from standard control flow.
   7.319 +    BOOST_COROUTINE_NORETURN(void exit_self()) {
   7.320 +      BOOST_ASSERT(!pending());
   7.321 +      BOOST_ASSERT(running());
   7.322 +      m_exit_state = ctx_exit_pending;	
   7.323 +      throw exit_exception();
   7.324 +    }
   7.325 +
   7.326 +    // Nothrow.
   7.327 +    ~context_base() throw() {
   7.328 +      BOOST_ASSERT(!running());
   7.329 +      try {
   7.330 +	if(!exited())
   7.331 +	  exit();
   7.332 +	BOOST_ASSERT(exited());
   7.333 +      } catch(...) {}
   7.334 +    }
   7.335 +
   7.336 +  protected:
   7.337 +    // global coroutine state
   7.338 +    enum context_state {
   7.339 +      ctx_running,  // context running.
   7.340 +      ctx_ready,    // context at yield point.
   7.341 +      ctx_waiting,     // context waiting for events.
   7.342 +      ctx_exited    // context is finished.
   7.343 +    };
   7.344 +
   7.345 +    // exit request state
   7.346 +    enum context_exit_state {
   7.347 +      ctx_exit_not_requested,  // exit not requested.
   7.348 +      ctx_exit_pending,   // exit requested.
   7.349 +      ctx_exit_signaled,  // exit request delivered.
   7.350 +    };
   7.351 +    
   7.352 +    // exit status
   7.353 +    enum context_exit_status {
   7.354 +      ctx_not_exited,
   7.355 +      ctx_exited_return,  // process exited by return.
   7.356 +      ctx_exited_exit,    // process exited by exit().
   7.357 +      ctx_exited_abnormally // process exited uncleanly.
   7.358 +    };
   7.359 +
   7.360 +    // Cause the coroutine to exit if 
   7.361 +    // a exit request is pending.
   7.362 +    // Throws: exit_exception if an exit request is pending.
   7.363 +    void check_exit_state() {
   7.364 +      BOOST_ASSERT(running());
   7.365 +      if(!m_exit_state) return;
   7.366 +      throw exit_exception();
   7.367 +    }
   7.368 +
   7.369 +    // Nothrow.
   7.370 +    void do_return(context_exit_status status, std::type_info const* info) throw() {
   7.371 +      BOOST_ASSERT(status != ctx_not_exited);
   7.372 +      BOOST_ASSERT(m_state == ctx_running);
   7.373 +      m_type_info = info;
   7.374 +      m_state = ctx_exited;
   7.375 +      m_exit_status = status;
   7.376 +      do_yield();
   7.377 +    }
   7.378 +
   7.379 +  private:
   7.380 +
   7.381 +    // Nothrow.
   7.382 +    void do_yield() throw() {
   7.383 +      swap_context(*this, m_caller, detail::yield_hint());
   7.384 +    }
   7.385 +
   7.386 +    // Nothrow.
   7.387 +    void do_invoke() throw (){
   7.388 +      BOOST_ASSERT(ready() || waiting());
   7.389 +      m_state = ctx_running;
   7.390 +      swap_context(m_caller, *this, detail::invoke_hint());
   7.391 +    }
   7.392 +
   7.393 +    template<typename ActualCtx>
   7.394 +    static void deleter (const type* ctx){
   7.395 +      delete static_cast<ActualCtx*>(const_cast<type*>(ctx));
   7.396 +    }
   7.397 +            
   7.398 +    typedef typename context_impl::context_impl_base ctx_type;
   7.399 +    ctx_type m_caller;
   7.400 +    mutable 
   7.401 +#ifndef BOOST_COROUTINE_USE_ATOMIC_COUNT
   7.402 +    std::size_t
   7.403 +#else
   7.404 +    boost::detail::atomic_count
   7.405 +#endif
   7.406 +    m_counter;
   7.407 +    deleter_type * m_deleter;
   7.408 +    context_state m_state;
   7.409 +    context_exit_state m_exit_state;
   7.410 +    context_exit_status m_exit_status;
   7.411 +    int m_wait_counter;   
   7.412 +    int m_operation_counter;    
   7.413 +
   7.414 +    // This is used to generate a meaningful exception trace.
   7.415 +    std::type_info const* m_type_info;
   7.416 +  };
   7.417 +
   7.418 +} } }
   7.419 +#endif
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/boost_1_45_0/boost/coroutine/detail/context_linux.hpp	Fri Mar 04 12:51:59 2011 -0800
     8.3 @@ -0,0 +1,285 @@
     8.4 +//  Copyright (c) 2006, Giovanni P. Deretta
     8.5 +//
     8.6 +//  This code may be used under either of the following two licences:
     8.7 +//
     8.8 +//  Permission is hereby granted, free of charge, to any person obtaining a copy 
     8.9 +//  of this software and associated documentation files (the "Software"), to deal 
    8.10 +//  in the Software without restriction, including without limitation the rights 
    8.11 +//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 
    8.12 +//  copies of the Software, and to permit persons to whom the Software is 
    8.13 +//  furnished to do so, subject to the following conditions:
    8.14 +//
    8.15 +//  The above copyright notice and this permission notice shall be included in 
    8.16 +//  all copies or substantial portions of the Software.
    8.17 +//
    8.18 +//  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
    8.19 +//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
    8.20 +//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
    8.21 +//  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
    8.22 +//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
    8.23 +//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 
    8.24 +//  THE SOFTWARE. OF SUCH DAMAGE.
    8.25 +//
    8.26 +//  Or:
    8.27 +//
    8.28 +//  Distributed under the Boost Software License, Version 1.0.
    8.29 +//  (See accompanying file LICENSE_1_0.txt or copy at
    8.30 +//  http://www.boost.org/LICENSE_1_0.txt)
    8.31 +
    8.32 +#ifndef BOOST_COROUTINE_CONTEXT_LINUX_HPP_20060601
    8.33 +#define BOOST_COROUTINE_CONTEXT_LINUX_HPP_20060601
    8.34 +
    8.35 +#if defined(__GNUC__) && defined(__i386__) && !defined(BOOST_COROUTINE_NO_ASM)
    8.36 +#include <cstdlib>
    8.37 +#include <cstddef>
    8.38 +#include <boost/coroutine/detail/posix_utility.hpp>
    8.39 +#include <boost/coroutine/detail/swap_context.hpp>
    8.40 +#include <boost/assert.hpp>
    8.41 +
    8.42 +/*
    8.43 + * Defining BOOST_COROUTINE_INLINE_ASM will enable the inlin3
    8.44 + * assembler verwsion of swapcontext_stack.
    8.45 + * The inline asm, with all required clobber flags, is usually no faster
    8.46 + * than the out-of-line function, and it is not yet clear if
    8.47 + * it is always reliable (i.e. if the compiler always saves the correct
    8.48 + * registers). FIXME: it is currently missing at least MMX and XMM registers in
    8.49 + * the clobber list.
    8.50 + */
    8.51 + 
    8.52 +/* 
    8.53 + * Defining BOOST_COROUTINE_NO_SEPARATE_CALL_SITES will disable separate 
    8.54 + * invoke, yield and yield_to swap_context functions. Separate calls sites
    8.55 + * increase performance by 25% at least on P4 for invoke+yield back loops
    8.56 + * at the cost of a slightly higher instruction cache use and is thus enabled by
    8.57 + * default.
    8.58 + */
    8.59 +//#define BOOST_COROUTINE_NO_SEPARATE_CALL_SITES
    8.60 +//#define BOOST_COROUTINE_INLINE_ASM
    8.61 +
    8.62 +
    8.63 +#ifndef BOOST_COROUTINE_INLINE_ASM
    8.64 +extern "C" void swapcontext_stack (void***, void**) throw()  __attribute((regparm(2)));
    8.65 +extern "C" void swapcontext_stack2 (void***, void**) throw()  __attribute((regparm(2)));
    8.66 +extern "C" void swapcontext_stack3 (void***, void**) throw()  __attribute((regparm(2)));
    8.67 +#else
    8.68 +
    8.69 +#  if 1
    8.70 +void 
    8.71 +inline
    8.72 +swapcontext_stack(void***from_sp, void**to_sp) throw() {
    8.73 +  asm volatile
    8.74 +    ("\n\t pushl %%ebp"
    8.75 +     "\n\t pushl %[from]"
    8.76 +     "\n\t pushl %[to]"
    8.77 +     "\n\t pushl $0f"
    8.78 +     "\n\t movl %%esp, (%[from])" 
    8.79 +     "\n\t movl %[to], %%esp"
    8.80 +     "\n\t popl %%ecx" 
    8.81 +     "\n\t jmp  *%%ecx"
    8.82 +     "\n0:\t popl %[to]"
    8.83 +     "\n\t popl %[from]"
    8.84 +     "\n\t popl %%ebp"
    8.85 +     :: 
    8.86 +     [from] "a" (from_sp),
    8.87 +     [to]   "d" (to_sp)
    8.88 +     :
    8.89 +     "cc", 
    8.90 +     "%ecx",
    8.91 +     "%ebx", 
    8.92 +     "%edi", 
    8.93 +     "%esi",
    8.94 +     "%st",
    8.95 +     "%st(1)",
    8.96 +     "%st(2)",
    8.97 +     "%st(3)",
    8.98 +     "%st(4)",
    8.99 +     "%st(5)",
   8.100 +     "%st(6)",
   8.101 +     "%st(7)",
   8.102 +     "memory"
   8.103 +   );
   8.104 +  
   8.105 +}
   8.106 +#  else
   8.107 +typedef   void (*fun_type)(void***from_sp, void**to_sp) 
   8.108 +  __attribute((regparm(2)));
   8.109 +
   8.110 +fun_type get_swapper();//  __attribute__((pure));
   8.111 +
   8.112 +inline 
   8.113 +fun_type get_swapper(){
   8.114 +  fun_type ptr;
   8.115 +  asm volatile("mov $0f, %[result]"
   8.116 +	       "\n\t jmp 1f"
   8.117 +	       "\n0:"
   8.118 +	       //"\n\t movl 16(%%edx), %%ecx"
   8.119 +	       "\n\t pushl %%ebp"
   8.120 +	       "\n\t pushl %%ebx"
   8.121 +	       "\n\t pushl %%esi"
   8.122 +	       "\n\t pushl %%edi"
   8.123 +	       "\n\t movl %%esp, (%%eax)"
   8.124 +	       "\n\t movl %%edx, %%esp"
   8.125 +	       "\n\t popl %%edi"
   8.126 +	       "\n\t popl %%esi"
   8.127 +	       "\n\t popl %%ebx"
   8.128 +	       "\n\t popl %%ebp"
   8.129 +	       "\n\t popl %%ecx"
   8.130 +	       "\n\t jmp *%%ecx"
   8.131 +	       "\n1:"
   8.132 +	       :
   8.133 +	       [result] "=g" (ptr) 
   8.134 +	       :       
   8.135 +	       );
   8.136 +  return ptr;
   8.137 +};
   8.138 +
   8.139 +void 
   8.140 +inline
   8.141 +swapcontext_stack(void***from_sp, void**to_sp) throw() {
   8.142 +  fun_type ptr = get_swapper();
   8.143 +  ptr(from_sp, to_sp);
   8.144 +}
   8.145 +
   8.146 +#  endif
   8.147 +
   8.148 +void 
   8.149 +inline
   8.150 +swapcontext_stack2(void***from_sp, void**to_sp) throw() {
   8.151 +  swapcontext_stack(from_sp, to_sp);
   8.152 +}
   8.153 +
   8.154 +#endif
   8.155 +
   8.156 +namespace boost { namespace coroutines { namespace detail {
   8.157 +  namespace oslinux {
   8.158 +    template<typename T>
   8.159 +    void trampoline(T* fun);
   8.160 +    
   8.161 +    template<typename T>
   8.162 +    inline
   8.163 +    void
   8.164 +    trampoline(T * fun) { 
   8.165 +      (*fun)();
   8.166 +      std::abort();
   8.167 +    }
   8.168 +
   8.169 +    class ia32_gcc_context_impl_base {
   8.170 +    public:
   8.171 +      ia32_gcc_context_impl_base() {};
   8.172 +
   8.173 +      void prefetch() const {
   8.174 +	__builtin_prefetch (m_sp, 1, 3);
   8.175 +	__builtin_prefetch (m_sp, 0, 3);
   8.176 +	__builtin_prefetch ((void**)m_sp+64/4, 1, 3);
   8.177 +	__builtin_prefetch ((void**)m_sp+64/4, 0, 3);
   8.178 +	__builtin_prefetch ((void**)m_sp+32/4, 1, 3);
   8.179 +	__builtin_prefetch ((void**)m_sp+32/4, 0, 3);
   8.180 +	__builtin_prefetch ((void**)m_sp-32/4, 1, 3);
   8.181 +	__builtin_prefetch ((void**)m_sp-32/4, 0, 3);
   8.182 +	__builtin_prefetch ((void**)m_sp-64/4, 1, 3);
   8.183 +	__builtin_prefetch ((void**)m_sp-64/4, 0, 3);
   8.184 +      }
   8.185 +
   8.186 +      /**
   8.187 +       * Free function. Saves the current context in @p from
   8.188 +       * and restores the context in @p to.
   8.189 +       * @note This function is found by ADL.
   8.190 +       */     
   8.191 +      friend 
   8.192 +      void 
   8.193 +      swap_context(ia32_gcc_context_impl_base& from, 
   8.194 +		   ia32_gcc_context_impl_base const& to, 
   8.195 +		   default_hint) {
   8.196 +	to.prefetch();
   8.197 +	swapcontext_stack(&from.m_sp, to.m_sp);
   8.198 +      }
   8.199 +
   8.200 +#ifndef BOOST_COROUTINE_NO_SEPARATE_CALL_SITES
   8.201 +      friend 
   8.202 +      void 
   8.203 +      swap_context(ia32_gcc_context_impl_base& from, 
   8.204 +		   ia32_gcc_context_impl_base const& to,
   8.205 +		   yield_hint) {
   8.206 +	to.prefetch();
   8.207 +	swapcontext_stack2(&from.m_sp, to.m_sp);
   8.208 +      }
   8.209 +
   8.210 +      friend 
   8.211 +      void 
   8.212 +      swap_context(ia32_gcc_context_impl_base& from, 
   8.213 +		   ia32_gcc_context_impl_base const& to,
   8.214 +		   yield_to_hint) {
   8.215 +	to.prefetch();
   8.216 +	swapcontext_stack2(&from.m_sp, to.m_sp);
   8.217 +      }
   8.218 +
   8.219 +#endif
   8.220 +
   8.221 +    protected:
   8.222 +      void ** m_sp;
   8.223 + 
   8.224 +    };
   8.225 +
   8.226 +    class ia32_gcc_context_impl  : public ia32_gcc_context_impl_base{
   8.227 +    public:
   8.228 +      enum {default_stack_size = 64*1024};
   8.229 +      
   8.230 +      typedef ia32_gcc_context_impl_base context_impl_base;
   8.231 +
   8.232 +      ia32_gcc_context_impl() :
   8.233 +	m_stack(0) {}
   8.234 +      /**
   8.235 +       * Create a context that on restore invokes Functor on
   8.236 +       *  a new stack. The stack size can be optionally specified.
   8.237 +       */
   8.238 +      template<typename Functor>
   8.239 +	  ia32_gcc_context_impl(Functor& cb, std::ptrdiff_t stack_size = -1) :
   8.240 +	m_stack_size(stack_size == -1? default_stack_size: stack_size),
   8.241 +	m_stack(posix::alloc_stack(m_stack_size)) {
   8.242 +	m_sp = ((void**)m_stack + (m_stack_size/sizeof(void*))),
   8.243 +	BOOST_ASSERT(m_stack);
   8.244 +	typedef void fun(Functor*);
   8.245 +	fun * funp = trampoline;
   8.246 +#ifndef BOOST_COROUTINE_INLINE_ASM
   8.247 +	*--m_sp = &cb;     // parm 0 of trampoline;
   8.248 +	*--m_sp = 0;        // dummy return address for trampoline
   8.249 +	*--m_sp = (void*) funp ;// return addr (here: start addr)  NOTE: the unsafe cast is safe on IA32
   8.250 +	*--m_sp = 0;       // ebp                                  
   8.251 +	*--m_sp = 0;       // ebx                                  
   8.252 +	*--m_sp = 0;       // esi                                  
   8.253 +	*--m_sp = 0;       // edi        
   8.254 +#else
   8.255 +	*--m_sp = &cb;     // parm 0 of trampoline;
   8.256 +	*--m_sp = 0;        // dummy return address for trampoline
   8.257 +	*--m_sp = (void*) funp ;// return addr (here: start addr)  NOTE: the unsafe cast is safe on IA32
   8.258 +#endif
   8.259 +      }
   8.260 +      
   8.261 +      ~ia32_gcc_context_impl() {
   8.262 +	if(m_stack)
   8.263 +	  posix::free_stack(m_stack, m_stack_size);
   8.264 +      }
   8.265 +
   8.266 +    private:
   8.267 +	  std::ptrdiff_t m_stack_size;
   8.268 +      void * m_stack;
   8.269 +    };
   8.270 +    
   8.271 +    typedef ia32_gcc_context_impl context_impl;
   8.272 +  }
   8.273 +} } }
   8.274 +
   8.275 +#elif defined(__linux)
   8.276 +/**
   8.277 + * For all other linux systems use the standard posix implementation.
   8.278 + */
   8.279 +#include <boost/coroutine/detail/context_posix.hpp>
   8.280 +namespace boost { namespace coroutines { namespace detail { namespace oslinux {
   8.281 +    typedef posix::context_impl context_impl;
   8.282 +} } } }
   8.283 +#else
   8.284 +#error This header can only be included when compiling for linux systems.
   8.285 +#endif
   8.286 +
   8.287 +
   8.288 +#endif
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/boost_1_45_0/boost/coroutine/detail/context_posix.hpp	Fri Mar 04 12:51:59 2011 -0800
     9.3 @@ -0,0 +1,231 @@
     9.4 +//  Copyright (c) 2006, Giovanni P. Deretta
     9.5 +//
     9.6 +//  This code may be used under either of the following two licences:
     9.7 +//
     9.8 +//  Permission is hereby granted, free of charge, to any person obtaining a copy 
     9.9 +//  of this software and associated documentation files (the "Software"), to deal 
    9.10 +//  in the Software without restriction, including without limitation the rights 
    9.11 +//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 
    9.12 +//  copies of the Software, and to permit persons to whom the Software is 
    9.13 +//  furnished to do so, subject to the following conditions:
    9.14 +//
    9.15 +//  The above copyright notice and this permission notice shall be included in 
    9.16 +//  all copies or substantial portions of the Software.
    9.17 +//
    9.18 +//  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
    9.19 +//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
    9.20 +//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
    9.21 +//  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
    9.22 +//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
    9.23 +//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 
    9.24 +//  THE SOFTWARE. OF SUCH DAMAGE.
    9.25 +//
    9.26 +//  Or:
    9.27 +//
    9.28 +//  Distributed under the Boost Software License, Version 1.0.
    9.29 +//  (See accompanying file LICENSE_1_0.txt or copy at
    9.30 +//  http://www.boost.org/LICENSE_1_0.txt)
    9.31 +
    9.32 +#ifndef BOOST_COROUTINE_CONTEXT_POSIX_HPP_20060601
    9.33 +#define BOOST_COROUTINE_CONTEXT_POSIX_HPP_20060601
    9.34 +
    9.35 +// NOTE (per http://lists.apple.com/archives/darwin-dev/2008/Jan/msg00232.html):
    9.36 +// > Why the bus error? What am I doing wrong? 
    9.37 +// This is a known issue where getcontext(3) is writing past the end of the
    9.38 +// ucontext_t struct when _XOPEN_SOURCE is not defined (rdar://problem/5578699 ).
    9.39 +// As a workaround, define _XOPEN_SOURCE before including ucontext.h.
    9.40 +#if defined(__APPLE__) && ! defined(_XOPEN_SOURCE)
    9.41 +#define _XOPEN_SOURCE
    9.42 +// However, the above #define will only affect <ucontext.h> if it has not yet
    9.43 +// been #included by something else!
    9.44 +#if defined(_STRUCT_UCONTEXT)
    9.45 +#error You must #include coroutine headers before anything that #includes <ucontext.h>
    9.46 +#endif
    9.47 +#endif
    9.48 +
    9.49 +#include <boost/config.hpp>
    9.50 +#include <boost/assert.hpp>
    9.51 +
    9.52 +#if defined(_XOPEN_UNIX) && defined(_XOPEN_VERSION) && _XOPEN_VERSION >= 500
    9.53 +
    9.54 +// OS X 10.4 -- despite passing the test above -- doesn't support
    9.55 +// swapcontext() et al. Use GNU Pth workalike functions.
    9.56 +#if defined(__APPLE__) && (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1050)
    9.57 +
    9.58 +#include "pth/pth.h"
    9.59 +#include <cerrno>
    9.60 +
    9.61 +namespace boost { namespace coroutines { namespace detail {
    9.62 +  namespace posix { namespace pth {
    9.63 +    inline int check(int rc)
    9.64 +    {
    9.65 +        // The makecontext() functions return zero for success, nonzero for
    9.66 +        // error. The Pth library returns TRUE for success, FALSE for error,
    9.67 +        // with errno set to the nonzero error in the latter case. Map the Pth
    9.68 +        // returns to ucontext style.
    9.69 +        return rc? 0 : errno;
    9.70 +    }
    9.71 +}}}}}
    9.72 +
    9.73 +#define BOOST_CORO_POSIX_IMPL "Pth implementation"
    9.74 +#define BOOST_CORO_DECLARE_CONTEXT(name) pth_uctx_t name
    9.75 +#define BOOST_CORO_CREATE_CONTEXT(ctx)                                  \
    9.76 +boost::coroutines::detail::posix::pth::check(pth_uctx_create(&(ctx)))
    9.77 +#define BOOST_CORO_MAKE_CONTEXT(ctx, stack, size, startfunc, startarg, exitto) \
    9.78 +/* const sigset_t* sigmask = NULL: we don't expect per-context signal masks */ \
    9.79 +boost::coroutines::detail::posix::pth::check(pth_uctx_make(*(ctx), static_cast<char*>(stack), (size), NULL, (startfunc), (startarg), (exitto)))
    9.80 +#define BOOST_CORO_SWAP_CONTEXT(from, to)                               \
    9.81 +boost::coroutines::detail::posix::pth::check(pth_uctx_switch(*(from), *(to)))
    9.82 +#define BOOST_CORO_DESTROY_CONTEXT(ctx)                                 \
    9.83 +boost::coroutines::detail::posix::pth::check(pth_uctx_destroy(ctx))
    9.84 +
    9.85 +#else // generic Posix platform (e.g. OS X >= 10.5)
    9.86 +
    9.87 +/*
    9.88 + * makecontext based context implementation. Should be available on all
    9.89 + * SuSv2 compliant UNIX systems. 
    9.90 + * NOTE: this implementation is not
    9.91 + * optimal as the makecontext API saves and restore the signal mask.
    9.92 + * This requires a system call for every context switch that really kills
    9.93 + * performance. Still is very portable and guaranteed to work.
    9.94 + * NOTE2: makecontext and friends are declared obsolescent in SuSv3, but
    9.95 + * it is unlikely that they will be removed any time soon.
    9.96 + */
    9.97 +#include <ucontext.h>
    9.98 +#include <cstddef>                  // ptrdiff_t
    9.99 +
   9.100 +namespace boost { namespace coroutines { namespace detail {
   9.101 +  namespace posix { namespace ucontext {
   9.102 +    inline int make_context(::ucontext_t* ctx, void* stack, std::ptrdiff_t size,
   9.103 +                            void (*startfunc)(void*), void* startarg, ::ucontext_t* exitto = NULL)
   9.104 +    {
   9.105 +        int error = ::getcontext(ctx);
   9.106 +        if (error)
   9.107 +            return error;
   9.108 +
   9.109 +        ctx->uc_stack.ss_sp = stack;
   9.110 +        ctx->uc_stack.ss_size = size;
   9.111 +        ctx->uc_link = exitto;
   9.112 +
   9.113 +        typedef void (*ctx_main)();
   9.114 +        //makecontext can't fail.
   9.115 +        ::makecontext(ctx,
   9.116 +                      (ctx_main)(startfunc), 
   9.117 +                      1,
   9.118 +                      startarg);
   9.119 +        return 0;
   9.120 +    }
   9.121 +}}}}}
   9.122 +
   9.123 +#define BOOST_CORO_POSIX_IMPL "ucontext implementation"
   9.124 +#define BOOST_CORO_DECLARE_CONTEXT(name) ::ucontext_t name
   9.125 +#define BOOST_CORO_CREATE_CONTEXT(ctx) /* nop */
   9.126 +#define BOOST_CORO_MAKE_CONTEXT(ctx, stack, size, startfunc, startarg, exitto) \
   9.127 +boost::coroutines::detail::posix::ucontext::make_context(ctx, stack, size, startfunc, startarg, exitto)
   9.128 +#define BOOST_CORO_SWAP_CONTEXT(pfrom, pto) ::swapcontext((pfrom), (pto))
   9.129 +#define BOOST_CORO_DESTROY_CONTEXT(ctx) /* nop */
   9.130 +
   9.131 +#endif // generic Posix platform
   9.132 +
   9.133 +#include <signal.h>                 // SIGSTKSZ
   9.134 +#include <boost/noncopyable.hpp>
   9.135 +#include <boost/coroutine/exception.hpp>
   9.136 +#include <boost/coroutine/detail/posix_utility.hpp>
   9.137 +#include <boost/coroutine/detail/swap_context.hpp>
   9.138 +namespace boost { namespace coroutines { namespace detail {
   9.139 +  namespace posix {
   9.140 +
   9.141 +
   9.142 +    /*
   9.143 +     * Posix implementation for the context_impl_base class.
   9.144 +     * @note context_impl is not required to be consistent
   9.145 +     * If not initialized it can only be swapped out, not in 
   9.146 +     * (at that point it will be initialized).
   9.147 +     *
   9.148 +     */
   9.149 +    class ucontext_context_impl_base {
   9.150 +    public:
   9.151 +      ucontext_context_impl_base()
   9.152 +      {
   9.153 +          BOOST_CORO_CREATE_CONTEXT(m_ctx);
   9.154 +      }
   9.155 +      ~ucontext_context_impl_base()
   9.156 +      {
   9.157 +          BOOST_CORO_DESTROY_CONTEXT(m_ctx);
   9.158 +      }
   9.159 +
   9.160 +    private:
   9.161 +      /*
   9.162 +       * Free function. Saves the current context in @p from
   9.163 +       * and restores the context in @p to.
   9.164 +       */     
   9.165 +      friend 
   9.166 +      void 
   9.167 +      swap_context(ucontext_context_impl_base& from, 
   9.168 +		   const ucontext_context_impl_base& to,
   9.169 +		   default_hint) {
   9.170 +	int  error = BOOST_CORO_SWAP_CONTEXT(&from.m_ctx, &to.m_ctx); 
   9.171 +	(void)error;
   9.172 +	BOOST_ASSERT(error == 0);
   9.173 +      }
   9.174 +
   9.175 +    protected:
   9.176 +      BOOST_CORO_DECLARE_CONTEXT(m_ctx);
   9.177 +    };
   9.178 +
   9.179 +    class ucontext_context_impl :
   9.180 +      public ucontext_context_impl_base,
   9.181 +      private boost::noncopyable {
   9.182 +    public:
   9.183 +      typedef ucontext_context_impl_base context_impl_base;
   9.184 +
   9.185 +      enum {default_stack_size = 64*1024};
   9.186 +
   9.187 +    
   9.188 +      /**
   9.189 +       * Create a context that on restore invokes Functor on
   9.190 +       *  a new stack. The stack size can be optionally specified.
   9.191 +       */
   9.192 +      template<typename Functor>
   9.193 +      explicit
   9.194 +	ucontext_context_impl(Functor& cb, std::ptrdiff_t stack_size) :
   9.195 +      m_stack_size(stack_size == -1? default_stack_size: stack_size),
   9.196 +      m_stack(alloc_stack(m_stack_size)) {
   9.197 +	BOOST_ASSERT(m_stack);
   9.198 +	typedef void cb_type(Functor*);
   9.199 +	cb_type * cb_ptr = &trampoline<Functor>;
   9.200 +        int error = BOOST_CORO_MAKE_CONTEXT(&m_ctx, m_stack, m_stack_size,
   9.201 +                                            (void (*)(void*))(cb_ptr), &cb, NULL);
   9.202 +	(void)error;
   9.203 +	BOOST_ASSERT(error == 0);
   9.204 +      }
   9.205 +      
   9.206 +      ~ucontext_context_impl() {
   9.207 +	if(m_stack)
   9.208 +	  free_stack(m_stack, m_stack_size);
   9.209 +      }
   9.210 +
   9.211 +    private:
   9.212 +      // declare m_stack_size first so we can use it to initialize m_stack
   9.213 +      std::ptrdiff_t m_stack_size;
   9.214 +      void * m_stack;
   9.215 +    };
   9.216 +
   9.217 +    typedef ucontext_context_impl context_impl;
   9.218 +  }
   9.219 +} } }
   9.220 +#else 
   9.221 +
   9.222 +/**
   9.223 + * This #else clause is essentially unchanged from the original Google Summer
   9.224 + * of Code version of Boost.Coroutine, which comments:
   9.225 + * "Context swapping can be implemented on most posix systems lacking *context
   9.226 + * using the sigaltstack+longjmp trick."
   9.227 + * This is in fact what the (highly portable) Pth library does, so if you
   9.228 + * encounter such a system, perhaps the best approach would be to twiddle the
   9.229 + * #if logic in this header to use the pth.h implementation above.
   9.230 + */
   9.231 +#error No context implementation for this POSIX system.
   9.232 +
   9.233 +#endif
   9.234 +#endif
    10.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.2 +++ b/boost_1_45_0/boost/coroutine/detail/context_windows.hpp	Fri Mar 04 12:51:59 2011 -0800
    10.3 @@ -0,0 +1,186 @@
    10.4 +//  Copyright (c) 2006, Giovanni P. Deretta
    10.5 +//
    10.6 +//  This code may be used under either of the following two licences:
    10.7 +//
    10.8 +//  Permission is hereby granted, free of charge, to any person obtaining a copy 
    10.9 +//  of this software and associated documentation files (the "Software"), to deal 
   10.10 +//  in the Software without restriction, including without limitation the rights 
   10.11 +//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 
   10.12 +//  copies of the Software, and to permit persons to whom the Software is 
   10.13 +//  furnished to do so, subject to the following conditions:
   10.14 +//
   10.15 +//  The above copyright notice and this permission notice shall be included in 
   10.16 +//  all copies or substantial portions of the Software.
   10.17 +//
   10.18 +//  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
   10.19 +//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
   10.20 +//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
   10.21 +//  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
   10.22 +//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
   10.23 +//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 
   10.24 +//  THE SOFTWARE. OF SUCH DAMAGE.
   10.25 +//
   10.26 +//  Or:
   10.27 +//
   10.28 +//  Distributed under the Boost Software License, Version 1.0.
   10.29 +//  (See accompanying file LICENSE_1_0.txt or copy at
   10.30 +//  http://www.boost.org/LICENSE_1_0.txt)
   10.31 +
   10.32 +#ifndef BOOST_COROUTINE_CONTEXT_WINDOWS_HPP_20060625
   10.33 +#define BOOST_COROUTINE_CONTEXT_WINDOWS_HPP_20060625
   10.34 +// This _WIN32_WINNT kludge is necessary to make winbase.h publish the Fiber API.
   10.35 +// 0x0400 makes CreateFiber(), etc., visible
   10.36 +// 0x0501 makes ConvertThreadToFiber() visible
   10.37 +// 0x0600 makes IsThreadAFiber() visible
   10.38 +// And no, I have no idea why this symbol isn't being set appropriately by
   10.39 +// the build environment.
   10.40 +#define WIN32_LEAN_AND_MEAN
   10.41 +#ifndef _WIN32_WINNT
   10.42 +#define _WIN32_WINNT 0x0600
   10.43 +// The above #define will only affect <windows.h> if it has not yet been
   10.44 +// #included by something else!
   10.45 +#endif // _WIN32_WINNT
   10.46 +#if defined(WINBASEAPI)
   10.47 +#error You must #include coroutine headers before anything that #includes <windows.h>
   10.48 +#endif
   10.49 +#include <windows.h>
   10.50 +#include <winnt.h>
   10.51 +#include <boost/config.hpp>
   10.52 +#include <boost/assert.hpp>
   10.53 +#include <boost/noncopyable.hpp>
   10.54 +#include <boost/coroutine/exception.hpp>
   10.55 +#include <boost/coroutine/detail/swap_context.hpp>
   10.56 +namespace boost {namespace coroutines {namespace detail{
   10.57 +  namespace windows {
   10.58 +
   10.59 +    typedef LPVOID fiber_ptr;
   10.60 +
   10.61 +    /*
   10.62 +     * This number (0x1E00) has been sighted in the wild (at least on windows XP systems)
   10.63 +     * as return value from GetCurrentFiber() on non fibrous threads. This is sowehow related
   10.64 +     * to OS/2 where the current fiber pointer is overloaded as a version field.
   10.65 +     * On non-NT systems, 0 is returned. 
   10.66 +     */
   10.67 +    const fiber_ptr fiber_magic = reinterpret_cast<fiber_ptr>(0x1E00);
   10.68 +		
   10.69 +    /*
   10.70 +     * Return true if current thread is a fiber.
   10.71 +     */
   10.72 +    inline
   10.73 +    bool is_fiber() {
   10.74 +#if _WIN32_WINNT >= 0x0600
   10.75 +      return bool(IsThreadAFiber());
   10.76 +#else
   10.77 +      fiber_ptr current = GetCurrentFiber();
   10.78 +      return current != 0 && current != fiber_magic;
   10.79 +#endif
   10.80 +    }
   10.81 +
   10.82 +    /*
   10.83 +     * Windows implementation for the context_impl_base class.
   10.84 +     * @note context_impl is not required to be consistent
   10.85 +     * If not initialized it can only be swapped out, not in 
   10.86 +     * (at that point it will be initialized).
   10.87 +     */
   10.88 +    class fibers_context_impl_base {
   10.89 +    public:
   10.90 +      /**
   10.91 +       * Create an empty context. 
   10.92 +       * An empty context cannot be restored from,
   10.93 +       * but can be saved in.
   10.94 +       */
   10.95 +      fibers_context_impl_base() :
   10.96 +	m_ctx(0) {}
   10.97 +	
   10.98 +      /*
   10.99 +       * Free function. Saves the current context in @p from
  10.100 +       * and restores the context in @p to. On windows the from
  10.101 +       * parameter is ignored. The current context is saved on the 
  10.102 +       * current fiber.
  10.103 +       * Note that if the current thread is not a fiber, it will be
  10.104 +       * converted to fiber on the fly on call and unconverted before
  10.105 +       * return. This is expensive. The user should convert the 
  10.106 +       * current thread to a fiber once on thread creation for better performance.
  10.107 +       * Note that we can't leave the thread unconverted on return or else we 
  10.108 +       * will leak resources on thread destruction. Do the right thing by
  10.109 +       * default.
  10.110 +       */     
  10.111 +      friend 
  10.112 +      void 
  10.113 +      swap_context(fibers_context_impl_base& from, 
  10.114 +		   const fibers_context_impl_base& to,
  10.115 +		   default_hint) {
  10.116 +	if(!is_fiber()) {
  10.117 +	  BOOST_ASSERT(from.m_ctx == 0);
  10.118 +	  from.m_ctx = ConvertThreadToFiber(0);
  10.119 +	  BOOST_ASSERT(from.m_ctx != 0);
  10.120 +	  
  10.121 +	  SwitchToFiber(to.m_ctx); 
  10.122 +	  
  10.123 +	  BOOL result = ConvertFiberToThread();
  10.124 +	  BOOST_ASSERT(result);
  10.125 +	  (void)result;
  10.126 +	  from.m_ctx = 0;
  10.127 +	} else {
  10.128 +	  bool call_from_main = from.m_ctx == 0;
  10.129 +	  if(call_from_main)
  10.130 +	    from.m_ctx = GetCurrentFiber();
  10.131 +	  SwitchToFiber(to.m_ctx); 
  10.132 +	  if(call_from_main)
  10.133 +	    from.m_ctx = 0;
  10.134 +	}
  10.135 +      }
  10.136 +
  10.137 +      ~fibers_context_impl_base() {}
  10.138 +    protected:
  10.139 +      explicit
  10.140 +      fibers_context_impl_base(fiber_ptr ctx) :
  10.141 +	m_ctx(ctx) {}
  10.142 +
  10.143 +      fiber_ptr m_ctx;
  10.144 +    };
  10.145 +
  10.146 +    template<typename T>
  10.147 +    inline
  10.148 +    VOID CALLBACK
  10.149 +    trampoline(LPVOID pv) {
  10.150 +      T* fun = static_cast<T*>(pv);
  10.151 +      BOOST_ASSERT(fun);
  10.152 +      (*fun)();
  10.153 +    }
  10.154 +
  10.155 +    class fibers_context_impl :
  10.156 +      public fibers_context_impl_base,
  10.157 +      private boost::noncopyable {
  10.158 +    public:
  10.159 +      typedef fibers_context_impl_base context_impl_base;
  10.160 +
  10.161 +      enum {default_stack_size = 64*1024};
  10.162 +
  10.163 +      /**
  10.164 +       * Create a context that on restore inovkes Functor on
  10.165 +       *  a new stack. The stack size can be optionally specified.
  10.166 +       */
  10.167 +      template<typename Functor>
  10.168 +      explicit
  10.169 +      fibers_context_impl(Functor& cb, std::ptrdiff_t stack_size) :
  10.170 +	fibers_context_impl_base
  10.171 +      (CreateFiber(stack_size== -1? 0 : stack_size,
  10.172 +		   static_cast<LPFIBER_START_ROUTINE>(&trampoline<Functor>),
  10.173 +		   static_cast<LPVOID>(&cb)))
  10.174 +      {
  10.175 +	BOOST_ASSERT(m_ctx);
  10.176 +      }
  10.177 +		  
  10.178 +      ~fibers_context_impl() {
  10.179 +	DeleteFiber(m_ctx);
  10.180 +      }
  10.181 +		  
  10.182 +    private:
  10.183 +    };
  10.184 +
  10.185 +    typedef fibers_context_impl context_impl;
  10.186 +
  10.187 +  }
  10.188 +} } }
  10.189 +#endif
    11.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.2 +++ b/boost_1_45_0/boost/coroutine/detail/coroutine_accessor.hpp	Fri Mar 04 12:51:59 2011 -0800
    11.3 @@ -0,0 +1,103 @@
    11.4 +//  Copyright (c) 2006, Giovanni P. Deretta
    11.5 +//
    11.6 +//  This code may be used under either of the following two licences:
    11.7 +//
    11.8 +//  Permission is hereby granted, free of charge, to any person obtaining a copy 
    11.9 +//  of this software and associated documentation files (the "Software"), to deal 
   11.10 +//  in the Software without restriction, including without limitation the rights 
   11.11 +//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 
   11.12 +//  copies of the Software, and to permit persons to whom the Software is 
   11.13 +//  furnished to do so, subject to the following conditions:
   11.14 +//
   11.15 +//  The above copyright notice and this permission notice shall be included in 
   11.16 +//  all copies or substantial portions of the Software.
   11.17 +//
   11.18 +//  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
   11.19 +//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
   11.20 +//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
   11.21 +//  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
   11.22 +//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
   11.23 +//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 
   11.24 +//  THE SOFTWARE. OF SUCH DAMAGE.
   11.25 +//
   11.26 +//  Or:
   11.27 +//
   11.28 +//  Distributed under the Boost Software License, Version 1.0.
   11.29 +//  (See accompanying file LICENSE_1_0.txt or copy at
   11.30 +//  http://www.boost.org/LICENSE_1_0.txt)
   11.31 +
   11.32 +#ifndef BOOST_COROUTINE_DETAIL_COROUTINE_ACCESSOR_HPP_20060709
   11.33 +#define BOOST_COROUTINE_DETAIL_COROUTINE_ACCESSOR_HPP_20060709
   11.34 +#include  <boost/utility/in_place_factory.hpp>
   11.35 +namespace boost { namespace coroutines { namespace detail {
   11.36 +  
   11.37 +  /*
   11.38 +   * This is a private interface used for coroutine
   11.39 +   * implementation.
   11.40 +   */
   11.41 +  struct init_from_impl_tag{};
   11.42 +  struct coroutine_accessor {
   11.43 +
   11.44 +    // Initialize coroutine from implementation type.
   11.45 +    // used by the in_place_assing in place factory.
   11.46 +    template<typename Coroutine, typename Ctx>
   11.47 +    static
   11.48 +    void construct(Ctx * src, void * address) {
   11.49 +      new (address) Coroutine(src, init_from_impl_tag());
   11.50 +    }
   11.51 +
   11.52 +    template<typename Coroutine>
   11.53 +    static 
   11.54 +    void acquire(Coroutine& x) {
   11.55 +      x.acquire();
   11.56 +    }
   11.57 +
   11.58 +    template<typename Coroutine>
   11.59 +    static
   11.60 +    void release(Coroutine& x) {
   11.61 +      x.release();
   11.62 +    }
   11.63 +
   11.64 +    template<typename Ctx>
   11.65 +    struct in_place_assign : boost::in_place_factory_base {
   11.66 +
   11.67 +      in_place_assign(Ctx * ctx) :
   11.68 +	m_ctx(ctx) {}
   11.69 +
   11.70 +      template<typename Coroutine>
   11.71 +      void apply(void * memory) const {
   11.72 +	construct<Coroutine>(m_ctx, memory);
   11.73 +      }
   11.74 +      Ctx * m_ctx;
   11.75 +    };
   11.76 +
   11.77 +    template<typename Ctx>
   11.78 +    static 
   11.79 +    in_place_assign<Ctx>
   11.80 +    in_place(Ctx * ctx) {
   11.81 +      return in_place_assign<Ctx>(ctx);
   11.82 +    }
   11.83 +
   11.84 +    template<typename Coroutine>
   11.85 +    static
   11.86 +    typename Coroutine::impl_ptr
   11.87 +    get_impl(Coroutine& x) {
   11.88 +      return x.get_impl();
   11.89 +    }
   11.90 +
   11.91 +    template<typename Coroutine>
   11.92 +    static
   11.93 +    typename Coroutine::impl_type *
   11.94 +    pilfer_impl(Coroutine& x) {
   11.95 +      return x.pilfer_impl();
   11.96 +    }
   11.97 +
   11.98 +    template<typename Coroutine>
   11.99 +    static
  11.100 +    std::size_t
  11.101 +    count(const Coroutine& x) {
  11.102 +      return x.count();
  11.103 +    }
  11.104 +  };
  11.105 +} } }
  11.106 +#endif
    12.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.2 +++ b/boost_1_45_0/boost/coroutine/detail/coroutine_impl.hpp	Fri Mar 04 12:51:59 2011 -0800
    12.3 @@ -0,0 +1,276 @@
    12.4 +//  Copyright (c) 2006, Giovanni P. Deretta
    12.5 +//
    12.6 +//  This code may be used under either of the following two licences:
    12.7 +//
    12.8 +//  Permission is hereby granted, free of charge, to any person obtaining a copy 
    12.9 +//  of this software and associated documentation files (the "Software"), to deal 
   12.10 +//  in the Software without restriction, including without limitation the rights 
   12.11 +//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 
   12.12 +//  copies of the Software, and to permit persons to whom the Software is 
   12.13 +//  furnished to do so, subject to the following conditions:
   12.14 +//
   12.15 +//  The above copyright notice and this permission notice shall be included in 
   12.16 +//  all copies or substantial portions of the Software.
   12.17 +//
   12.18 +//  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
   12.19 +//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
   12.20 +//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
   12.21 +//  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
   12.22 +//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
   12.23 +//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 
   12.24 +//  THE SOFTWARE. OF SUCH DAMAGE.
   12.25 +//
   12.26 +//  Or:
   12.27 +//
   12.28 +//  Distributed under the Boost Software License, Version 1.0.
   12.29 +//  (See accompanying file LICENSE_1_0.txt or copy at
   12.30 +//  http://www.boost.org/LICENSE_1_0.txt)
   12.31 +
   12.32 +#ifndef BOOST_COROUTINE_COROUTINE_IMPL_HPP_20060601
   12.33 +#define BOOST_COROUTINE_COROUTINE_IMPL_HPP_20060601
   12.34 +#if defined(_MSC_VER)
   12.35 +#pragma warning (push)
   12.36 +#pragma warning (disable: 4355) //this used in base member initializer
   12.37 +#endif 
   12.38 +
   12.39 +#include <cstddef>
   12.40 +#include <boost/optional.hpp>
   12.41 +#include <boost/coroutine/detail/argument_unpacker.hpp>
   12.42 +#include <boost/coroutine/detail/coroutine_accessor.hpp>
   12.43 +#include <boost/coroutine/detail/context_base.hpp>
   12.44 +
   12.45 +namespace boost { namespace coroutines { namespace detail {
   12.46 +	
   12.47 +  // This class augment the contest_base class with
   12.48 +  // the coroutine signature type.
   12.49 +  // This is mostly just a place to put
   12.50 +  // typesafe argument and result type pointers.
   12.51 +  template<typename CoroutineType, typename ContextImpl>
   12.52 +  class coroutine_impl:
   12.53 +    public context_base<ContextImpl>
   12.54 +  {
   12.55 +  public:
   12.56 +    template<typename DerivedType, typename ResultType>
   12.57 +    friend class add_result;
   12.58 +
   12.59 +    typedef ContextImpl context_impl;
   12.60 +    typedef CoroutineType coroutine_type;
   12.61 +    typedef coroutine_impl<coroutine_type, context_impl> type;
   12.62 +    typedef context_base<context_impl> context_base_type;
   12.63 +    typedef typename coroutine_type::arg_slot_type arg_slot_type;
   12.64 +    typedef typename coroutine_type::result_type result_type;
   12.65 +    typedef typename coroutine_type::result_slot_type result_slot_type;
   12.66 +
   12.67 +    typedef boost::intrusive_ptr<type> pointer;
   12.68 +  
   12.69 +    template<typename DerivedType>
   12.70 +	coroutine_impl(DerivedType * this_, std::ptrdiff_t stack_size) :
   12.71 +      context_base_type(*this_, stack_size),
   12.72 +	m_arg(0),
   12.73 +	m_result(0){}
   12.74 +                
   12.75 +    arg_slot_type * args() {
   12.76 +      BOOST_ASSERT(m_arg);
   12.77 +      return m_arg;
   12.78 +    };
   12.79 +    
   12.80 +    result_slot_type * result() {
   12.81 +      BOOST_ASSERT(m_result);
   12.82 +      BOOST_ASSERT(*m_result);
   12.83 +      return *this->m_result;
   12.84 +    } 
   12.85 +
   12.86 +    template<typename Functor>
   12.87 +	static inline	
   12.88 +	pointer create(Functor, std::ptrdiff_t);
   12.89 +
   12.90 +    void bind_args(arg_slot_type* arg) {
   12.91 +      m_arg = arg;
   12.92 +    }
   12.93 +    
   12.94 +    void bind_result(result_slot_type* res) {
   12.95 +      // This used to be unconditional. But m_result isn't always valid.
   12.96 +      if (m_result) {
   12.97 +        *m_result = res;
   12.98 +      }
   12.99 +    }
  12.100 +
  12.101 +    // Another level of indirecition is needed to handle
  12.102 +    // yield_to correctly.
  12.103 +    void bind_result_pointer(result_slot_type** resp) {
  12.104 +      m_result = resp;
  12.105 +    }
  12.106 +
  12.107 +    result_slot_type** result_pointer() {
  12.108 +      return m_result;
  12.109 +    }
  12.110 +
  12.111 +    /// This helper class packages data/logic originally found inline in
  12.112 +    /// coroutine::call_impl() and call_impl_nothrow(), also
  12.113 +    /// coroutine_impl::run().
  12.114 +    class local_result_slot_ptr
  12.115 +    {
  12.116 +    public:
  12.117 +        local_result_slot_ptr(pointer pimpl):
  12.118 +            m_pimpl(pimpl),
  12.119 +            m_ptr(NULL)
  12.120 +        {
  12.121 +            m_pimpl->bind_result_pointer(&m_ptr);
  12.122 +        }
  12.123 +        ~local_result_slot_ptr()
  12.124 +        {
  12.125 +            // In the original use case, a coroutine could only be resumed by
  12.126 +            // calling coroutine::operator() again, which would rebind the
  12.127 +            // result pointer to a new valid value. But with the introduction
  12.128 +            // of futures, it's possible to suspend a coroutine by waiting on
  12.129 +            // a future object -- thus destroying the local result_slot_type*
  12.130 +            // -- then resume that coroutine by calling the future's callback,
  12.131 +            // bypassing coroutine::operator(). This used to leave an old,
  12.132 +            // invalid result pointer in effect. Subsequent coroutine exit
  12.133 +            // wrote through that pointer, munging a word of stack. Now we
  12.134 +            // make a point of setting the bound result pointer NULL when the
  12.135 +            // result_slot_type* to which it pointed vanishes, so that any
  12.136 +            // attempt to dereference it will at least self-identify --
  12.137 +            // instead of producing arbitrary undefined behavior.
  12.138 +            m_pimpl->bind_result_pointer(NULL);
  12.139 +        }
  12.140 +
  12.141 +    private:
  12.142 +        pointer m_pimpl;
  12.143 +        result_slot_type* m_ptr;
  12.144 +    };
  12.145 +
  12.146 +    // This function must be called only for void
  12.147 +    // coroutines. It wakes up the coroutine.
  12.148 +    // Entering the wait state does not cause this
  12.149 +    // method to throw.
  12.150 +    void run() {
  12.151 +      arg_slot_type void_args;
  12.152 +      
  12.153 +      // This dummy binding is required because
  12.154 +      // do_call expect args() and result()
  12.155 +      // to return a non NULL result.
  12.156 +      bind_args(&void_args);
  12.157 +      local_result_slot_pointer(this);
  12.158 +      this->wake_up();
  12.159 +    }
  12.160 +  protected:
  12.161 +    boost::optional<result_slot_type>  m_result_last;
  12.162 +
  12.163 +  private:
  12.164 +    arg_slot_type * m_arg;
  12.165 +    result_slot_type ** m_result;
  12.166 +
  12.167 +  };
  12.168 +
  12.169 +  // This type augment coroutine_impl type with the type of the stored 
  12.170 +  // functor. The type of this object is erased right after construction
  12.171 +  // when it is assigned to a pointer to coroutine_impl. A deleter is
  12.172 +  // passed down to make it sure that the correct derived type is deleted.
  12.173 +  template<typename FunctorType, typename CoroutineType, typename ContextImpl>
  12.174 +  class coroutine_impl_wrapper :
  12.175 +    public coroutine_impl<CoroutineType, ContextImpl> {
  12.176 +  public:
  12.177 +    typedef coroutine_impl_wrapper<FunctorType, CoroutineType, ContextImpl> 
  12.178 +    type;
  12.179 +    typedef CoroutineType coroutine_type;
  12.180 +    typedef typename CoroutineType::result_type result_type;
  12.181 +    typedef coroutine_impl<CoroutineType, ContextImpl> super_type;
  12.182 +
  12.183 +    typedef FunctorType functor_type;
  12.184 +	coroutine_impl_wrapper(functor_type f, std::ptrdiff_t stack_size) :
  12.185 +
  12.186 +		super_type(this, stack_size),
  12.187 +      m_fun(f){}
  12.188 +
  12.189 +    void operator()() {
  12.190 +      typedef typename super_type::context_exit_status
  12.191 +	context_exit_status;
  12.192 +      context_exit_status status = super_type::ctx_exited_return;
  12.193 +      std::type_info const* tinfo = 0;
  12.194 +      try {
  12.195 +	this->check_exit_state();
  12.196 +	do_call<result_type>();
  12.197 +      } catch (const exit_exception&) {
  12.198 +	status = super_type::ctx_exited_exit;
  12.199 +      } catch (std::exception const& e) {
  12.200 +	status = super_type::ctx_exited_abnormally;
  12.201 +	tinfo = &typeid(e);
  12.202 +      } catch (...) {
  12.203 +	status = super_type::ctx_exited_abnormally;
  12.204 +      }
  12.205 +      this->do_return(status, tinfo);	  
  12.206 +    }
  12.207 +  public:    
  12.208 +
  12.209 +    //GCC workaround as per enable_if docs 
  12.210 +    template <int> struct dummy { dummy(int) {} };
  12.211 +    /*
  12.212 +     * Implementation for operator()
  12.213 +     * This is for void result types.
  12.214 +     * Can throw if m_fun throws. At least it can throw exit_exception.
  12.215 +     */
  12.216 +    template<typename ResultType>
  12.217 +    typename boost::enable_if<boost::is_void<ResultType> >::type
  12.218 +    do_call(dummy<0> = 0) {
  12.219 +      BOOST_ASSERT(this->count() > 0);
  12.220 +      typedef BOOST_DEDUCED_TYPENAME
  12.221 +	coroutine_type::self self_type;
  12.222 +      boost::optional<self_type> self (coroutine_accessor::in_place(this));
  12.223 +      detail::unpack_ex
  12.224 +	(m_fun, 
  12.225 +	 *self, 
  12.226 +	 *this->args(), 
  12.227 +	 detail::trait_tag<typename coroutine_type::arg_slot_traits>());
  12.228 +
  12.229 +      typedef BOOST_DEDUCED_TYPENAME coroutine_type::result_slot_type 
  12.230 +	result_slot_type;
  12.231 +
  12.232 +      // In this particulare case result_slot_type is guaranteed to be
  12.233 +      // default constructible.
  12.234 +      this->m_result_last = result_slot_type();
  12.235 +      this->bind_result(&*this->m_result_last);
  12.236 +    }
  12.237 +
  12.238 +    // Same as above, but for non void result types.
  12.239 +    template<typename ResultType>
  12.240 +    typename boost::disable_if<boost::is_void<ResultType> >::type
  12.241 +    do_call(dummy<1> = 1) {
  12.242 +      BOOST_ASSERT(this->count() > 0);
  12.243 +      typedef BOOST_DEDUCED_TYPENAME
  12.244 +      coroutine_type::self self_type;
  12.245 +
  12.246 +      boost::optional<self_type> self (coroutine_accessor::in_place(this));
  12.247 +
  12.248 +      typedef BOOST_DEDUCED_TYPENAME coroutine_type::arg_slot_traits traits;
  12.249 +      typedef BOOST_DEDUCED_TYPENAME coroutine_type::result_slot_type 
  12.250 +	result_slot_type;
  12.251 +	  
  12.252 +      this->m_result_last = boost::in_place(result_slot_type(detail::unpack_ex
  12.253 +			   (m_fun, 
  12.254 +			    *self, 
  12.255 +			    *this->args(), 
  12.256 +			    detail::trait_tag<traits>())));      
  12.257 +      
  12.258 +      this->bind_result(&*this->m_result_last);
  12.259 +    }
  12.260 +  
  12.261 +    FunctorType m_fun;
  12.262 +  };
  12.263 +
  12.264 +  template<typename CoroutineType, typename ContextImpl>
  12.265 +  template<typename Functor>
  12.266 +  inline
  12.267 +  typename 
  12.268 +  coroutine_impl<CoroutineType, ContextImpl>::pointer
  12.269 +  coroutine_impl<CoroutineType, ContextImpl>::
  12.270 +  create(Functor f, std::ptrdiff_t stack_size = default_stack_size) {
  12.271 +    return new coroutine_impl_wrapper<Functor, CoroutineType, ContextImpl>
  12.272 +      (f, stack_size);      
  12.273 +  }
  12.274 +
  12.275 +} } }
  12.276 +#if defined(_MSC_VER)
  12.277 +#pragma warning(pop)
  12.278 +#endif
  12.279 +#endif
    13.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.2 +++ b/boost_1_45_0/boost/coroutine/detail/coroutine_traits.hpp	Fri Mar 04 12:51:59 2011 -0800
    13.3 @@ -0,0 +1,82 @@
    13.4 +//  Copyright (c) 2006, Giovanni P. Deretta
    13.5 +//
    13.6 +//  This code may be used under either of the following two licences:
    13.7 +//
    13.8 +//  Permission is hereby granted, free of charge, to any person obtaining a copy 
    13.9 +//  of this software and associated documentation files (the "Software"), to deal 
   13.10 +//  in the Software without restriction, including without limitation the rights 
   13.11 +//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 
   13.12 +//  copies of the Software, and to permit persons to whom the Software is 
   13.13 +//  furnished to do so, subject to the following conditions:
   13.14 +//
   13.15 +//  The above copyright notice and this permission notice shall be included in 
   13.16 +//  all copies or substantial portions of the Software.
   13.17 +//
   13.18 +//  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
   13.19 +//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
   13.20 +//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
   13.21 +//  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
   13.22 +//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
   13.23 +//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 
   13.24 +//  THE SOFTWARE. OF SUCH DAMAGE.
   13.25 +//
   13.26 +//  Or:
   13.27 +//
   13.28 +//  Distributed under the Boost Software License, Version 1.0.
   13.29 +//  (See accompanying file LICENSE_1_0.txt or copy at
   13.30 +//  http://www.boost.org/LICENSE_1_0.txt)
   13.31 +
   13.32 +#ifndef BOOST_COROUTINE_DETAIL_COROUTINE_TRAITS_HPP_20060613
   13.33 +#define BOOST_COROUTINE_DETAIL_COROUTINE_TRAITS_HPP_20060613
   13.34 +#include <boost/type_traits.hpp>
   13.35 +#include <boost/coroutine/tuple_traits.hpp>
   13.36 +#include <boost/coroutine/detail/yield_result_type.hpp>
   13.37 +
   13.38 +namespace boost { namespace coroutines { namespace detail {
   13.39 +
   13.40 +  template<typename T>
   13.41 +  struct as_tuple {
   13.42 +    typedef typename T::as_tuple type;
   13.43 +  };
   13.44 +
   13.45 +  // This trait class is used to compute
   13.46 +  // all nested typedefs of coroutines given
   13.47 +  // a signature in the form 'result_type(parm1, ... parmn)'.
   13.48 +  template<typename Signature>
   13.49 +  struct coroutine_traits {    
   13.50 +  private:
   13.51 +
   13.52 +    typedef BOOST_DEDUCED_TYPENAME boost::function_traits<Signature>::result_type 
   13.53 +    signature_result_type;
   13.54 +  public:
   13.55 +    typedef BOOST_DEDUCED_TYPENAME
   13.56 +    boost::mpl::eval_if<is_tuple_traits<signature_result_type>,
   13.57 +			as_tuple<signature_result_type>,
   13.58 +			boost::mpl::identity<signature_result_type> >
   13.59 +    ::type result_type;
   13.60 +
   13.61 +    typedef BOOST_DEDUCED_TYPENAME
   13.62 +    boost::mpl::eval_if<is_tuple_traits<signature_result_type>,
   13.63 +			boost::mpl::identity<signature_result_type>,
   13.64 +			boost::mpl::if_
   13.65 +			<boost::is_same<signature_result_type, void>,
   13.66 +			 tuple_traits<>,
   13.67 +			 tuple_traits<signature_result_type> > >
   13.68 +    ::type result_slot_traits;
   13.69 +    
   13.70 +    typedef BOOST_DEDUCED_TYPENAME result_slot_traits
   13.71 +    ::as_tuple result_slot_type;
   13.72 +    	     
   13.73 +    typedef BOOST_DEDUCED_TYPENAME detail::make_tuple_traits
   13.74 +    <typename detail::signature<Signature>::type >
   13.75 +    ::type arg_slot_traits;
   13.76 +
   13.77 +    typedef BOOST_DEDUCED_TYPENAME arg_slot_traits
   13.78 +    ::as_tuple arg_slot_type;
   13.79 +
   13.80 +    typedef BOOST_DEDUCED_TYPENAME arg_slot_traits
   13.81 +    ::as_result yield_result_type;
   13.82 +
   13.83 +  };
   13.84 +} } }
   13.85 +#endif
    14.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.2 +++ b/boost_1_45_0/boost/coroutine/detail/default_context_impl.hpp	Fri Mar 04 12:51:59 2011 -0800
    14.3 @@ -0,0 +1,122 @@
    14.4 +//  Copyright (c) 2006, Giovanni P. Deretta
    14.5 +//
    14.6 +//  This code may be used under either of the following two licences:
    14.7 +//
    14.8 +//  Permission is hereby granted, free of charge, to any person obtaining a copy 
    14.9 +//  of this software and associated documentation files (the "Software"), to deal 
   14.10 +//  in the Software without restriction, including without limitation the rights 
   14.11 +//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 
   14.12 +//  copies of the Software, and to permit persons to whom the Software is 
   14.13 +//  furnished to do so, subject to the following conditions:
   14.14 +//
   14.15 +//  The above copyright notice and this permission notice shall be included in 
   14.16 +//  all copies or substantial portions of the Software.
   14.17 +//
   14.18 +//  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
   14.19 +//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
   14.20 +//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
   14.21 +//  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
   14.22 +//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
   14.23 +//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 
   14.24 +//  THE SOFTWARE. OF SUCH DAMAGE.
   14.25 +//
   14.26 +//  Or:
   14.27 +//
   14.28 +//  Distributed under the Boost Software License, Version 1.0.
   14.29 +//  (See accompanying file LICENSE_1_0.txt or copy at
   14.30 +//  http://www.boost.org/LICENSE_1_0.txt)
   14.31 +
   14.32 +#ifndef BOOST_COROUTINE_DEFAULT_CONTEXT_IMPL_HPP_20060601
   14.33 +#define BOOST_COROUTINE_DEFAULT_CONTEXT_IMPL_HPP_20060601
   14.34 +#include <boost/config.hpp>
   14.35 +/* 
   14.36 +   ContextImpl concept documentation.
   14.37 +   A ContextImpl holds a context plus its stack.
   14.38 +   - ContextImpl must have constructor with the following signature:
   14.39 +   
   14.40 +     template<typename Functor>
   14.41 +     ContextImpl(Functor f, std::ptrdiff_t stack_size);
   14.42 +	 
   14.43 +     Preconditions:
   14.44 +     f is a generic function object (support for function pointers
   14.45 +     is not required.
   14.46 +     stack_size is the size of the stack allocated
   14.47 +     for the context. The stack_size is only an hint. If stack_size is -1
   14.48 +     it should default to a sensible value. 
   14.49 +     Postconditions:
   14.50 +     f is bound to this context in its own stack.
   14.51 +     When the context is activated with swap_context for the first time
   14.52 +     f is entered. 
   14.53 +     
   14.54 +   - ContextImpl destructor must properly dispose of the stack and perform
   14.55 +     any other clean up action required.	 
   14.56 +       
   14.57 +   - ContextImpl is not required to be DefaultConstructible nor Copyable.
   14.58 +	 
   14.59 +   - ContextImpl must expose the following typedef:
   14.60 +
   14.61 +     typedef unspecified-type context_impl_base;
   14.62 +       
   14.63 +     ContextImpl must be convertible to context_impl_base. 
   14.64 +     context_impl_base must have conform to the ContextImplBase concept:
   14.65 +       
   14.66 +     - DefaultConstructible. A default constructed ContextImplBase is in
   14.67 +       an unitialized state. 
   14.68 +       A ContextImpl is an initialized ContextImplBase.
   14.69 +
   14.70 +     - ContextImplBase is Copyable. A copy of a ContextImplBase holds
   14.71 +       The same informations as the original. Once a ContextImplBase
   14.72 +       is used as an argument to swap_context, all its copies become stale.
   14.73 +       (that is, only one copy of ContextImplBase can be used).
   14.74 +       A ContextImpl cannot be sliced by copying it to a ContextImplBase.
   14.75 +	   
   14.76 +     - void swap_context(ContextImplBase& from, 
   14.77 +	                 const ContextImplBase& to) 
   14.78 +	 
   14.79 +       This free function is called unqualified (via ADL).
   14.80 +       Preconditions:
   14.81 +       Its 'to' argument must be an initialized ContextImplBase.
   14.82 +       Its 'from' argument may be an uninitialized ContextImplBase that
   14.83 +       will be initialized by a swap_context.
   14.84 +       Postconditions:
   14.85 +       The current context is saved in the 'from' context, and the
   14.86 +       'to' context is restored. 
   14.87 +       It is undefined behaviour if the 'to' argument is an invalid 
   14.88 +       (uninitialized) swapcontext.
   14.89 +	   
   14.90 +     A ContextImplBase is meant to be used when an empty temporary
   14.91 +     context is needed to store the current context before
   14.92 +     restoring a ContextImpl and no current context is
   14.93 +     available. It could be possible to simply have ContextImpl
   14.94 +     default constructible, but on destruciton it would need to
   14.95 +     check if a stack has been allocated and would slow down the
   14.96 +     fast invcation path. Also a stackful context could not be
   14.97 +     make copiable.
   14.98 +*/
   14.99 +
  14.100 +#if defined(__linux) || defined(linux) || defined(__linux__)
  14.101 +
  14.102 +#include <boost/coroutine/detail/context_linux.hpp>
  14.103 +namespace boost { namespace coroutines { namespace detail {
  14.104 +  typedef oslinux::context_impl default_context_impl;
  14.105 +} } }
  14.106 +
  14.107 +#elif defined(_POSIX_VERSION)
  14.108 +
  14.109 +#include <boost/coroutine/detail/context_posix.hpp>
  14.110 +namespace boost { namespace coroutines { namespace detail {
  14.111 +  typedef posix::context_impl default_context_impl;
  14.112 +} } }
  14.113 +#elif defined(BOOST_WINDOWS)
  14.114 +#include <boost/coroutine/detail/context_windows.hpp>
  14.115 +namespace boost { namespace coroutines { namespace detail {
  14.116 +  typedef windows::context_impl default_context_impl;
  14.117 +} } }
  14.118 +
  14.119 +#else 
  14.120 +
  14.121 +#error No default_context_impl available for this system
  14.122 +
  14.123 +#endif
  14.124 +
  14.125 +#endif
    15.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.2 +++ b/boost_1_45_0/boost/coroutine/detail/fix_result.hpp	Fri Mar 04 12:51:59 2011 -0800
    15.3 @@ -0,0 +1,61 @@
    15.4 +//  Copyright (c) 2006, Giovanni P. Deretta
    15.5 +//
    15.6 +//  This code may be used under either of the following two licences:
    15.7 +//
    15.8 +//  Permission is hereby granted, free of charge, to any person obtaining a copy 
    15.9 +//  of this software and associated documentation files (the "Software"), to deal 
   15.10 +//  in the Software without restriction, including without limitation the rights 
   15.11 +//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 
   15.12 +//  copies of the Software, and to permit persons to whom the Software is 
   15.13 +//  furnished to do so, subject to the following conditions:
   15.14 +//
   15.15 +//  The above copyright notice and this permission notice shall be included in 
   15.16 +//  all copies or substantial portions of the Software.
   15.17 +//
   15.18 +//  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
   15.19 +//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
   15.20 +//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
   15.21 +//  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
   15.22 +//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
   15.23 +//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 
   15.24 +//  THE SOFTWARE. OF SUCH DAMAGE.
   15.25 +//
   15.26 +//  Or:
   15.27 +//
   15.28 +//  Distributed under the Boost Software License, Version 1.0.
   15.29 +//  (See accompanying file LICENSE_1_0.txt or copy at
   15.30 +//  http://www.boost.org/LICENSE_1_0.txt)
   15.31 +
   15.32 +#ifndef BOOST_COROUTINE_DETAIL_FIX_RESULT_HPP_20060709
   15.33 +#define BOOST_COROUTINE_DETAIL_FIX_RESULT_HPP_20060709
   15.34 +#include <boost/utility/enable_if.hpp>
   15.35 +namespace boost { namespace coroutines { namespace detail {
   15.36 +    template<typename Traits>
   15.37 +    inline
   15.38 +    void
   15.39 +    fix_result(const typename Traits::as_tuple&, 
   15.40 +	       typename 
   15.41 +	       boost::enable_if_c<Traits::length == 0>::type * = 0){}
   15.42 +
   15.43 +
   15.44 +    template<typename Traits>
   15.45 +    inline
   15.46 +    typename Traits::template at<0>::type
   15.47 +    fix_result(const typename Traits::as_tuple& x, 
   15.48 +	       typename 
   15.49 +	       boost::enable_if_c<Traits::length == 1>::type * = 0){
   15.50 +      using boost::get;
   15.51 +      return get<0>(x);
   15.52 +    }
   15.53 +
   15.54 +
   15.55 +    template<typename Traits>
   15.56 +    inline
   15.57 +    typename Traits::as_tuple
   15.58 +    fix_result(const typename Traits::as_tuple& x, 
   15.59 +	       typename 
   15.60 +	       boost::enable_if_c<(Traits::length > 1)>::type* =0){
   15.61 +      return x;
   15.62 +    }
   15.63 +} } }
   15.64 +#endif
    16.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.2 +++ b/boost_1_45_0/boost/coroutine/detail/future_impl.hpp	Fri Mar 04 12:51:59 2011 -0800
    16.3 @@ -0,0 +1,140 @@
    16.4 +//  Copyright (c) 2006, Giovanni P. Deretta
    16.5 +//
    16.6 +//  This code may be used under either of the following two licences:
    16.7 +//
    16.8 +//  Permission is hereby granted, free of charge, to any person obtaining a copy 
    16.9 +//  of this software and associated documentation files (the "Software"), to deal 
   16.10 +//  in the Software without restriction, including without limitation the rights 
   16.11 +//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 
   16.12 +//  copies of the Software, and to permit persons to whom the Software is 
   16.13 +//  furnished to do so, subject to the following conditions:
   16.14 +//
   16.15 +//  The above copyright notice and this permission notice shall be included in 
   16.16 +//  all copies or substantial portions of the Software.
   16.17 +//
   16.18 +//  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
   16.19 +//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
   16.20 +//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
   16.21 +//  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
   16.22 +//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
   16.23 +//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 
   16.24 +//  THE SOFTWARE. OF SUCH DAMAGE.
   16.25 +//
   16.26 +//  Or:
   16.27 +//
   16.28 +//  Distributed under the Boost Software License, Version 1.0.
   16.29 +//  (See accompanying file LICENSE_1_0.txt or copy at
   16.30 +//  http://www.boost.org/LICENSE_1_0.txt)
   16.31 +
   16.32 +#ifndef BOOST_COROUTINE_DETAIL_FUTURE_IMPL_HPP_20060809
   16.33 +#define BOOST_COROUTINE_DETAIL_FUTURE_IMPL_HPP_20060809
   16.34 +#include <boost/optional.hpp>
   16.35 +#include <boost/assert.hpp>
   16.36 +#include <boost/optional.hpp>
   16.37 +#include <boost/noncopyable.hpp>
   16.38 +#include <boost/coroutine/detail/coroutine_accessor.hpp>
   16.39 +#include <boost/coroutine/detail/context_base.hpp>
   16.40 +
   16.41 +namespace boost { namespace coroutines { namespace detail {
   16.42 +
   16.43 +
   16.44 +  template<typename ValueType, typename ContextImpl>
   16.45 +  class future_impl : boost::noncopyable  {
   16.46 +  public:
   16.47 +    typedef ValueType value_type;
   16.48 +    typedef 
   16.49 +    context_base<ContextImpl> *      
   16.50 +    context_weak_pointer;
   16.51 +    
   16.52 +    typedef 
   16.53 +    BOOST_DEDUCED_TYPENAME
   16.54 +    context_base<ContextImpl>::pointer
   16.55 +    context_pointer;
   16.56 +
   16.57 +    typedef boost::optional<value_type> pointer;
   16.58 +
   16.59 +    template<typename CoroutineSelf>
   16.60 +    future_impl(CoroutineSelf& self) :
   16.61 +      m_coro_impl_weak(coroutine_accessor::get_impl(self)),
   16.62 +      m_coro_impl(0),
   16.63 +      m_waited(false)
   16.64 +    {}
   16.65 +
   16.66 +    value_type& 
   16.67 +    value() {
   16.68 +      return *m_optional;
   16.69 +    }
   16.70 +
   16.71 +    value_type const& 
   16.72 +    value() const{
   16.73 +      return *m_optional;
   16.74 +    }
   16.75 +
   16.76 +    pointer& 
   16.77 +    get() {
   16.78 +      return m_optional;
   16.79 +    }
   16.80 +
   16.81 +    pointer const& 
   16.82 +    get() const{
   16.83 +      return m_optional;
   16.84 +    }
   16.85 +
   16.86 +    bool pending() {
   16.87 +      return 0 != m_coro_impl.get();
   16.88 +    }
   16.89 +    
   16.90 +    template<typename T>
   16.91 +    void assign(const T& val) {
   16.92 +      BOOST_ASSERT(pending());
   16.93 +      context_pointer p = m_coro_impl;
   16.94 +      m_coro_impl = 0;
   16.95 +      m_optional = val;
   16.96 +      p->count_down();
   16.97 +      if(waited() && p->signal())
   16.98 +	p->wake_up();
   16.99 +    }
  16.100 +
  16.101 +    void mark_pending() {
  16.102 +      m_coro_impl = m_coro_impl_weak;
  16.103 +      m_coro_impl ->count_up();
  16.104 +    }
  16.105 +
  16.106 +    void mark_wait(bool how) {
  16.107 +      m_waited = how;
  16.108 +    }
  16.109 +
  16.110 +    bool waited() const {
  16.111 +      return m_waited;
  16.112 +    }
  16.113 +
  16.114 +    context_pointer context() {
  16.115 +      BOOST_ASSERT(pending());
  16.116 +      return m_coro_impl;
  16.117 +    }
  16.118 +        
  16.119 +    void wait(int n) {
  16.120 +      m_coro_impl_weak->wait(n);
  16.121 +    }
  16.122 +
  16.123 +    void wait() {
  16.124 +      if(!pending()) return;
  16.125 +      mark_wait(true);
  16.126 +      try {
  16.127 +	m_coro_impl->wait(1);
  16.128 +	BOOST_ASSERT(!pending());
  16.129 +      } catch (...) {
  16.130 +	mark_wait(false);
  16.131 +	throw;
  16.132 +      }
  16.133 +      mark_wait(false);
  16.134 +    }
  16.135 +
  16.136 +  private:
  16.137 +    context_weak_pointer m_coro_impl_weak;
  16.138 +    context_pointer m_coro_impl;
  16.139 +    bool m_waited;
  16.140 +    boost::optional<value_type> m_optional;
  16.141 +  };
  16.142 +} } }
  16.143 +#endif
    17.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    17.2 +++ b/boost_1_45_0/boost/coroutine/detail/has_swap.hpp	Fri Mar 04 12:51:59 2011 -0800
    17.3 @@ -0,0 +1,84 @@
    17.4 +//  Copyright (c) 2006, Giovanni P. Deretta
    17.5 +//
    17.6 +//  This code may be used under either of the following two licences:
    17.7 +//
    17.8 +//  Permission is hereby granted, free of charge, to any person obtaining a copy 
    17.9 +//  of this software and associated documentation files (the "Software"), to deal 
   17.10 +//  in the Software without restriction, including without limitation the rights 
   17.11 +//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 
   17.12 +//  copies of the Software, and to permit persons to whom the Software is 
   17.13 +//  furnished to do so, subject to the following conditions:
   17.14 +//
   17.15 +//  The above copyright notice and this permission notice shall be included in 
   17.16 +//  all copies or substantial portions of the Software.
   17.17 +//
   17.18 +//  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
   17.19 +//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
   17.20 +//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
   17.21 +//  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
   17.22 +//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
   17.23 +//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 
   17.24 +//  THE SOFTWARE. OF SUCH DAMAGE.
   17.25 +//
   17.26 +//  Or:
   17.27 +//
   17.28 +//  Distributed under the Boost Software License, Version 1.0.
   17.29 +//  (See accompanying file LICENSE_1_0.txt or copy at
   17.30 +//  http://www.boost.org/LICENSE_1_0.txt)
   17.31 +
   17.32 +
   17.33 +// Copyright David Abrahams 2004. Distributed under the Boost
   17.34 +// Software License, Version 1.0. (See accompanying
   17.35 +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
   17.36 +// 
   17.37 +// Slightly modified for inclusion on coroutines/detail library.
   17.38 +#ifndef BOOST_COROUTINE_DETAIL_HAS_SWAP_HPP_20060709
   17.39 +#define BOOST_COROUTINE_DETAIL_HAS_SWAP_HPP_20060709
   17.40 +
   17.41 +#include <boost/mpl/bool.hpp>
   17.42 +#include <boost/detail/workaround.hpp>
   17.43 +
   17.44 +namespace boost { namespace coroutines {
   17.45 +
   17.46 +
   17.47 +namespace has_swap_
   17.48 +{
   17.49 +  // any soaks up implicit conversions and makes the following
   17.50 +  // operator++ less-preferred than any other such operator which
   17.51 +  // might be found via ADL.
   17.52 +  struct anything { template <class T> anything(T const&); };
   17.53 +  struct no_swap
   17.54 +  {
   17.55 +      char (& operator,(char) )[2];
   17.56 +  };
   17.57 +  no_swap swap(anything,anything);
   17.58 +    
   17.59 +#if defined(BOOST_MSVC)
   17.60 +# pragma warning(push)
   17.61 +# pragma warning(disable: 4675) // function found through argument dependent lookup -- duh!
   17.62 +#endif 
   17.63 +  template <class T>
   17.64 +  struct has_swap_impl
   17.65 +  {
   17.66 +      static T& x;
   17.67 +        
   17.68 +      BOOST_STATIC_CONSTANT(bool, value = sizeof(swap(x,x),'x') == 1);
   17.69 +      
   17.70 +#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
   17.71 +      typedef boost::mpl::bool_<has_swap_impl<T>::value> type;
   17.72 +#else
   17.73 +      typedef boost::mpl::bool_<value> type;
   17.74 +#endif      
   17.75 +  };
   17.76 +}
   17.77 +template <class T>
   17.78 +struct has_swap
   17.79 +  : has_swap_::has_swap_impl<T>::type
   17.80 +{};
   17.81 +#if defined(BOOST_MSVC)
   17.82 +# pragma warning(pop)
   17.83 +#endif 
   17.84 +
   17.85 +} } 
   17.86 +
   17.87 +#endif // include guard
    18.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    18.2 +++ b/boost_1_45_0/boost/coroutine/detail/index.hpp	Fri Mar 04 12:51:59 2011 -0800
    18.3 @@ -0,0 +1,42 @@
    18.4 +//  Copyright (c) 2006, Giovanni P. Deretta
    18.5 +//
    18.6 +//  This code may be used under either of the following two licences:
    18.7 +//
    18.8 +//  Permission is hereby granted, free of charge, to any person obtaining a copy 
    18.9 +//  of this software and associated documentation files (the "Software"), to deal 
   18.10 +//  in the Software without restriction, including without limitation the rights 
   18.11 +//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 
   18.12 +//  copies of the Software, and to permit persons to whom the Software is 
   18.13 +//  furnished to do so, subject to the following conditions:
   18.14 +//
   18.15 +//  The above copyright notice and this permission notice shall be included in 
   18.16 +//  all copies or substantial portions of the Software.
   18.17 +//
   18.18 +//  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
   18.19 +//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
   18.20 +//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
   18.21 +//  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
   18.22 +//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
   18.23 +//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 
   18.24 +//  THE SOFTWARE. OF SUCH DAMAGE.
   18.25 +//
   18.26 +//  Or:
   18.27 +//
   18.28 +//  Distributed under the Boost Software License, Version 1.0.
   18.29 +//  (See accompanying file LICENSE_1_0.txt or copy at
   18.30 +//  http://www.boost.org/LICENSE_1_0.txt)
   18.31 +
   18.32 +#ifndef BOOST_COROUTINE_DETAIL_INDEX_HPP_20060613
   18.33 +#define BOOST_COROUTINE_DETAIL_INDEX_HPP_20060613
   18.34 +#include <boost/preprocessor/repetition.hpp>
   18.35 +#include <boost/coroutine/detail/arg_max.hpp>
   18.36 +namespace boost { namespace coroutines { namespace detail {
   18.37 +  /* 
   18.38 +   * Workaround for BOOST_PP_ENUM_BINARY_PARAMS, where a token
   18.39 +   * can't be createed by appending a number to a '<'.
   18.40 +   * NOTE: we are really abusing BOOST_PP_ENUM_BINARY_PARAMS,
   18.41 +   * Should simply use BOOST_PP_ENUM.
   18.42 +   */
   18.43 +  enum {BOOST_PP_ENUM_PARAMS(BOOST_COROUTINE_ARG_MAX, index_)};
   18.44 +} } }
   18.45 +#endif 
    19.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    19.2 +++ b/boost_1_45_0/boost/coroutine/detail/is_callable.hpp	Fri Mar 04 12:51:59 2011 -0800
    19.3 @@ -0,0 +1,62 @@
    19.4 +//  Copyright (c) 2006, Giovanni P. Deretta
    19.5 +//
    19.6 +//  This code may be used under either of the following two licences:
    19.7 +//
    19.8 +//  Permission is hereby granted, free of charge, to any person obtaining a copy 
    19.9 +//  of this software and associated documentation files (the "Software"), to deal 
   19.10 +//  in the Software without restriction, including without limitation the rights 
   19.11 +//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 
   19.12 +//  copies of the Software, and to permit persons to whom the Software is 
   19.13 +//  furnished to do so, subject to the following conditions:
   19.14 +//
   19.15 +//  The above copyright notice and this permission notice shall be included in 
   19.16 +//  all copies or substantial portions of the Software.
   19.17 +//
   19.18 +//  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
   19.19 +//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
   19.20 +//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
   19.21 +//  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
   19.22 +//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
   19.23 +//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 
   19.24 +//  THE SOFTWARE. OF SUCH DAMAGE.
   19.25 +//
   19.26 +//  Or:
   19.27 +//
   19.28 +//  Distributed under the Boost Software License, Version 1.0.
   19.29 +//  (See accompanying file LICENSE_1_0.txt or copy at
   19.30 +//  http://www.boost.org/LICENSE_1_0.txt)
   19.31 +
   19.32 +#ifndef BOOST_COROUTINE_DETAIL_IS_CALLABLE_HPP_20060601
   19.33 +#define BOOST_COROUTINE_DETAIL_IS_CALLABLE_HPP_20060601
   19.34 +#include <boost/utility/enable_if.hpp>
   19.35 +#include <boost/type_traits.hpp>
   19.36 +#include <boost/mpl/logical.hpp>
   19.37 +#include <boost/mpl/has_xxx.hpp>
   19.38 +namespace boost { namespace coroutines { namespace detail {
   19.39 +  template<typename T>
   19.40 +  struct is_function_pointer : 
   19.41 +    boost::mpl::and_<
   19.42 +    boost::is_pointer<T>,
   19.43 +    boost::is_function<typename boost::remove_pointer<T>::type > > {
   19.44 +    typedef is_function_pointer<T> type;
   19.45 +  };
   19.46 +
   19.47 +  BOOST_MPL_HAS_XXX_TRAIT_DEF(result_type);
   19.48 +  BOOST_MPL_HAS_XXX_TRAIT_DEF(result);
   19.49 +  
   19.50 +  template<typename T>
   19.51 +  struct is_functor : 
   19.52 +    boost::mpl::or_<typename has_result_type<T>::type,
   19.53 +		    typename has_result<T>::type>
   19.54 +  {
   19.55 +    typedef is_functor<T> type;
   19.56 +  };
   19.57 +
   19.58 +  template<typename T>
   19.59 +  struct is_callable : boost::mpl::or_<
   19.60 +    is_functor<T>,
   19.61 +    is_function_pointer<T> >::type {
   19.62 +    typedef is_callable<T> type;
   19.63 +  };
   19.64 +} } }
   19.65 +#endif
    20.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    20.2 +++ b/boost_1_45_0/boost/coroutine/detail/make_tuple_traits.hpp	Fri Mar 04 12:51:59 2011 -0800
    20.3 @@ -0,0 +1,67 @@
    20.4 +//  Copyright (c) 2006, Giovanni P. Deretta
    20.5 +//
    20.6 +//  This code may be used under either of the following two licences:
    20.7 +//
    20.8 +//  Permission is hereby granted, free of charge, to any person obtaining a copy 
    20.9 +//  of this software and associated documentation files (the "Software"), to deal 
   20.10 +//  in the Software without restriction, including without limitation the rights 
   20.11 +//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 
   20.12 +//  copies of the Software, and to permit persons to whom the Software is 
   20.13 +//  furnished to do so, subject to the following conditions:
   20.14 +//
   20.15 +//  The above copyright notice and this permission notice shall be included in 
   20.16 +//  all copies or substantial portions of the Software.
   20.17 +//
   20.18 +//  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
   20.19 +//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
   20.20 +//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
   20.21 +//  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
   20.22 +//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
   20.23 +//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 
   20.24 +//  THE SOFTWARE. OF SUCH DAMAGE.
   20.25 +//
   20.26 +//  Or:
   20.27 +//
   20.28 +//  Distributed under the Boost Software License, Version 1.0.
   20.29 +//  (See accompanying file LICENSE_1_0.txt or copy at
   20.30 +//  http://www.boost.org/LICENSE_1_0.txt)
   20.31 +
   20.32 +#ifndef BOOST_COROUTINE_DETAIL_MAKE_TUPLE_TRAITS_HPP_20060609
   20.33 +#define BOOST_COROUTINE_DETAIL_MAKE_TUPLE_TRAITS_HPP_20060609
   20.34 +#include <boost/preprocessor/repetition.hpp>
   20.35 +#include <boost/mpl/vector.hpp>
   20.36 +#include <boost/coroutine/detail/arg_max.hpp>
   20.37 +#include <boost/coroutine/tuple_traits.hpp>
   20.38 +
   20.39 +namespace boost { namespace coroutines { namespace detail {
   20.40 +  /*
   20.41 +   * Given a mpl::vector, returns a nullary metafunction
   20.42 +   * describing a tuple of all types in the vector.
   20.43 +   * NOTE this is just wrong because it should work for all mpl
   20.44 +   * sequences, not just vectors. But it is in detail, so leave it
   20.45 +   * as is. Eventually it will be replaced by Boost.Fusion.
   20.46 +   * @p type is a tuple of all types in TypeList.
   20.47 +   * TypeList is one of mpl::vector0, mpl::vector1, etc.
   20.48 +   */
   20.49 +  template<typename TypeList>
   20.50 +  struct make_tuple_traits;
   20.51 +
   20.52 +#define BOOST_COROUTINE_MAKE_TUPLE_TRAITS_GENERATOR(z, n, unused)       \
   20.53 +    template<BOOST_PP_ENUM_PARAMS(n, class A)>                   \
   20.54 +    struct make_tuple_traits<BOOST_PP_CAT(boost::mpl::vector, n)        \
   20.55 +        <BOOST_PP_ENUM_PARAMS(n, A)> >{                          \
   20.56 +        typedef tuple_traits<BOOST_PP_ENUM_PARAMS(n, A)> type;   \
   20.57 +    };                                                           \
   20.58 +/**/
   20.59 +
   20.60 +  /**
   20.61 +   * Generate specializations of make_tuple
   20.62 +   * @note This could be done more elegantly with a recursive metafunction, 
   20.63 +   * but this is simpler and works well anyway.
   20.64 +   */
   20.65 +  BOOST_PP_REPEAT(BOOST_COROUTINE_ARG_MAX, 
   20.66 +		  BOOST_COROUTINE_MAKE_TUPLE_TRAITS_GENERATOR, ~);
   20.67 +#undef BOOST_COROUTINE_MAKE_TUPLE_TRAITS_GENERATOR
   20.68 +
   20.69 +} } }
   20.70 +#endif 
    21.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    21.2 +++ b/boost_1_45_0/boost/coroutine/detail/noreturn.hpp	Fri Mar 04 12:51:59 2011 -0800
    21.3 @@ -0,0 +1,68 @@
    21.4 +//  Copyright (c) 2006, Giovanni P. Deretta
    21.5 +//
    21.6 +//  This code may be used under either of the following two licences:
    21.7 +//
    21.8 +//  Permission is hereby granted, free of charge, to any person obtaining a copy 
    21.9 +//  of this software and associated documentation files (the "Software"), to deal 
   21.10 +//  in the Software without restriction, including without limitation the rights 
   21.11 +//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 
   21.12 +//  copies of the Software, and to permit persons to whom the Software is 
   21.13 +//  furnished to do so, subject to the following conditions:
   21.14 +//
   21.15 +//  The above copyright notice and this permission notice shall be included in 
   21.16 +//  all copies or substantial portions of the Software.
   21.17 +//
   21.18 +//  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
   21.19 +//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
   21.20 +//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
   21.21 +//  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
   21.22 +//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
   21.23 +//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 
   21.24 +//  THE SOFTWARE. OF SUCH DAMAGE.
   21.25 +//
   21.26 +//  Or:
   21.27 +//
   21.28 +//  Distributed under the Boost Software License, Version 1.0.
   21.29 +//  (See accompanying file LICENSE_1_0.txt or copy at
   21.30 +//  http://www.boost.org/LICENSE_1_0.txt)
   21.31 +
   21.32 +#ifndef BOOST_COROUTINE_DETAIL_NORETURN_HPP_20060812
   21.33 +#define BOOST_COROUTINE_DETAIL_NORETURN_HPP_20060812
   21.34 +/*
   21.35 + * The BOOST_COROUTINE_NORETURN macro provides a way to 
   21.36 + * tell the compiler that a function will not return through
   21.37 + * the normal return path (it could return throgh a thrown exception).
   21.38 + * This not only provieds a possible optimization hint, but also
   21.39 + * prevents the compiler from complaining if a function that call
   21.40 + * a noreturn function does not call return itself.
   21.41 + */
   21.42 +#include <boost/config.hpp>
   21.43 +
   21.44 +#if defined(__GNUC__)
   21.45 +
   21.46 +#if __GNUC_MAJOR__ > 3 || (__GNUC_MAJOR__ == 3 && __GNUC_MINOR__ > 3)
   21.47 +#define BOOST_COROUTINE_NORETURN(function) \
   21.48 +    function __attribute__((__noreturn__)) \
   21.49 +/**/
   21.50 +#else // gcc 3.3
   21.51 +#define BOOST_COROUTINE_NORETURN(function) \
   21.52 +    function
   21.53 +/**/
   21.54 +#endif // gcc 3.3
   21.55 +  
   21.56 +#elif defined (BOOST_MSVC)
   21.57 +
   21.58 +#define BOOST_COROUTINE_NORETURN(function) \
   21.59 +    __declspec(noreturn) function          \
   21.60 +/**/
   21.61 +
   21.62 +#else
   21.63 +//just for testing, remove the following error.
   21.64 +#error no default
   21.65 +#define BOOST_COROUTINE_NORETURN(function) \
   21.66 +    function
   21.67 +/**/
   21.68 +
   21.69 +#endif
   21.70 +
   21.71 +#endif
    22.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    22.2 +++ b/boost_1_45_0/boost/coroutine/detail/posix_utility.hpp	Fri Mar 04 12:51:59 2011 -0800
    22.3 @@ -0,0 +1,162 @@
    22.4 +//  Copyright (c) 2006, Giovanni P. Deretta
    22.5 +//
    22.6 +//  This code may be used under either of the following two licences:
    22.7 +//
    22.8 +//  Permission is hereby granted, free of charge, to any person obtaining a copy 
    22.9 +//  of this software and associated documentation files (the "Software"), to deal 
   22.10 +//  in the Software without restriction, including without limitation the rights 
   22.11 +//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 
   22.12 +//  copies of the Software, and to permit persons to whom the Software is 
   22.13 +//  furnished to do so, subject to the following conditions:
   22.14 +//
   22.15 +//  The above copyright notice and this permission notice shall be included in 
   22.16 +//  all copies or substantial portions of the Software.
   22.17 +//
   22.18 +//  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
   22.19 +//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
   22.20 +//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
   22.21 +//  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
   22.22 +//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
   22.23 +//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 
   22.24 +//  THE SOFTWARE. OF SUCH DAMAGE.
   22.25 +//
   22.26 +//  Or:
   22.27 +//
   22.28 +//  Distributed under the Boost Software License, Version 1.0.
   22.29 +//  (See accompanying file LICENSE_1_0.txt or copy at
   22.30 +//  http://www.boost.org/LICENSE_1_0.txt)
   22.31 +
   22.32 +#ifndef BOOST_COROUTINE_DETAIL_POSIX_UTILITY_HPP_02012006
   22.33 +#define BOOST_COROUTINE_DETAIL_POSIX_UTILITY_HPP_02012006
   22.34 +#include <boost/config.hpp>
   22.35 +
   22.36 +#if defined(_POSIX_VERSION)
   22.37 +/**
   22.38 + * Most of these utilities are really pure C++, but they are useful
   22.39 + * only on posix systems.
   22.40 + */
   22.41 +#include <cerrno>
   22.42 +#include <cstddef>
   22.43 +#include <cstdlib>
   22.44 +#include <iostream>
   22.45 +#include <cstring>
   22.46 +#include <boost/type_traits.hpp>
   22.47 +#if defined(_POSIX_MAPPED_FILES) && _POSIX_MAPPED_FILES > 0
   22.48 +#include <sys/mman.h>
   22.49 +#endif
   22.50 +/**
   22.51 + * Stack allocation routines and trampolines for setcontext
   22.52 + */
   22.53 +namespace boost { namespace coroutines { namespace detail { namespace posix {
   22.54 +
   22.55 +#if defined(_POSIX_MAPPED_FILES) && _POSIX_MAPPED_FILES > 0
   22.56 +
   22.57 +  inline 
   22.58 +  void * 
   22.59 +  alloc_stack(std::size_t size) {
   22.60 +    void * stack = ::mmap(NULL,
   22.61 +			  size,
   22.62 +			  PROT_EXEC|PROT_READ|PROT_WRITE,
   22.63 +#if defined(__APPLE__)
   22.64 +			  MAP_PRIVATE|MAP_ANON,
   22.65 +#else // ! __APPLE__
   22.66 +			  MAP_PRIVATE|MAP_ANONYMOUS,
   22.67 +#endif // ! __APPLE__
   22.68 +			  -1,
   22.69 +			  0
   22.70 +			  );
   22.71 +    if(stack == MAP_FAILED) {
   22.72 +      std::cerr <<strerror(errno)<<"\n";
   22.73 +      abort();
   22.74 +    }
   22.75 +    return stack;
   22.76 +  }
   22.77 +
   22.78 +  inline
   22.79 +  void free_stack(void* stack, std::size_t size) {
   22.80 +    ::munmap(stack, size);
   22.81 +  }
   22.82 +
   22.83 +#else  // non-mmap()
   22.84 +  
   22.85 +  //this should be a fine default.
   22.86 +  static const std::size_t stack_alignment = sizeof(void*) > 16? sizeof(void*): 16;
   22.87 +
   22.88 +  struct stack_aligner {
   22.89 +    boost::type_with_alignment<stack_alignment>::type dummy;
   22.90 +  };
   22.91 +
   22.92 +  /**
   22.93 +   * Stack allocator and deleter functions.
   22.94 +   * Better implementations are possible using
   22.95 +   * mmap (might be required on some systems) and/or
   22.96 +   * using a pooling allocator.
   22.97 +   * NOTE: the SuSv3 documentation explictly allows
   22.98 +   * the use of malloc to allocate stacks for makectx.
   22.99 +   * We use free for guaranteed alignment.
  22.100 +   */
  22.101 +  inline
  22.102 +  void* alloc_stack(std::size_t size) {
  22.103 +    return new stack_aligner[size/sizeof(stack_aligner)];
  22.104 +  }
  22.105 +
  22.106 +  inline
  22.107 +  void free_stack(void* stack, std::size_t size) {
  22.108 +    delete [] static_cast<stack_aligner*>(stack);
  22.109 +  }
  22.110 +
  22.111 +#endif  // non-mmap() implementation of alloc_stack()/free_stack()
  22.112 +
  22.113 +  /**
  22.114 +   * The splitter is needed for 64 bit systems. 
  22.115 +   * @note The current implementation does NOT use
  22.116 +   * (for debug reasons).
  22.117 +   * Thus it is not 64 bit clean.
  22.118 +   * Use it for 64 bits systems.
  22.119 +   */
  22.120 +  template<typename T>
  22.121 +  union splitter {
  22.122 +    int int_[2];
  22.123 +    T* ptr;
  22.124 +    splitter(int first, int second) {
  22.125 +      int_[0] = first;
  22.126 +      int_[1] = second;
  22.127 +    }
  22.128 +
  22.129 +    int first() {
  22.130 +      return int_[0];
  22.131 +    }
  22.132 +
  22.133 +    int second() {
  22.134 +      return int_[1];
  22.135 +    }
  22.136 +
  22.137 +    splitter(T* ptr) :ptr(ptr) {}
  22.138 +
  22.139 +    void operator()() {
  22.140 +      (*ptr)();
  22.141 +    }
  22.142 +  };
  22.143 +
  22.144 +  template<typename T>
  22.145 +  inline
  22.146 +  void
  22.147 +  trampoline_split(int first, int second) {
  22.148 +    splitter<T> split(first, second);
  22.149 +    split();
  22.150 +  }
  22.151 +
  22.152 +  template<typename T>
  22.153 +  inline
  22.154 +  void
  22.155 +  trampoline(T * fun) {
  22.156 +    (*fun)();
  22.157 +  }
  22.158 +}
  22.159 +} } }
  22.160 +
  22.161 +#else
  22.162 +#error This header can only be included when compiling for posix systems.
  22.163 +#endif
  22.164 +
  22.165 +#endif
    23.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    23.2 +++ b/boost_1_45_0/boost/coroutine/detail/self.hpp	Fri Mar 04 12:51:59 2011 -0800
    23.3 @@ -0,0 +1,274 @@
    23.4 +//  Copyright (c) 2006, Giovanni P. Deretta
    23.5 +//
    23.6 +//  This code may be used under either of the following two licences:
    23.7 +//
    23.8 +//  Permission is hereby granted, free of charge, to any person obtaining a copy 
    23.9 +//  of this software and associated documentation files (the "Software"), to deal 
   23.10 +//  in the Software without restriction, including without limitation the rights 
   23.11 +//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 
   23.12 +//  copies of the Software, and to permit persons to whom the Software is 
   23.13 +//  furnished to do so, subject to the following conditions:
   23.14 +//
   23.15 +//  The above copyright notice and this permission notice shall be included in 
   23.16 +//  all copies or substantial portions of the Software.
   23.17 +//
   23.18 +//  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
   23.19 +//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
   23.20 +//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
   23.21 +//  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
   23.22 +//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
   23.23 +//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 
   23.24 +//  THE SOFTWARE. OF SUCH DAMAGE.
   23.25 +//
   23.26 +//  Or:
   23.27 +//
   23.28 +//  Distributed under the Boost Software License, Version 1.0.
   23.29 +//  (See accompanying file LICENSE_1_0.txt or copy at
   23.30 +//  http://www.boost.org/LICENSE_1_0.txt)
   23.31 +
   23.32 +#ifndef BOOST_COROUTINE_DETAIL_SELF_HPP_20060809
   23.33 +#define BOOST_COROUTINE_DETAIL_SELF_HPP_20060809
   23.34 +#include <boost/noncopyable.hpp>
   23.35 +#include <boost/coroutine/detail/fix_result.hpp>
   23.36 +#include <boost/coroutine/detail/coroutine_accessor.hpp>
   23.37 +#include <boost/coroutine/detail/signal.hpp>
   23.38 +#include <boost/detail/workaround.hpp>
   23.39 +#include <boost/coroutine/detail/noreturn.hpp>
   23.40 +
   23.41 +namespace boost { namespace coroutines { namespace detail {
   23.42 +
   23.43 +#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1400))
   23.44 +#define BOOST_COROUTINE_DEDUCED_TYPENAME_DEFAULT
   23.45 +#else
   23.46 +#define BOOST_COROUTINE_DEDUCED_TYPENAME_DEFAULT BOOST_DEDUCED_TYPENAME
   23.47 +#endif
   23.48 +
   23.49 +#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1400))
   23.50 +#define BOOST_COROUTINE_VCPP80_WORKAROUND 
   23.51 +#else
   23.52 +//for now, define this unconditionally for testing.
   23.53 +#define BOOST_COROUTINE_VCPP80_WORKAROUND 
   23.54 +#endif
   23.55 +
   23.56 +  template<typename Coroutine>
   23.57 +  class coroutine_self :boost::noncopyable {
   23.58 +  public:
   23.59 +    typedef Coroutine coroutine_type;
   23.60 +    typedef coroutine_self<coroutine_type> type;
   23.61 +    friend struct detail::coroutine_accessor;
   23.62 +
   23.63 +    typedef BOOST_DEDUCED_TYPENAME coroutine_type
   23.64 +    ::impl_type impl_type;
   23.65 +
   23.66 +    // Note, no reference counting here.
   23.67 +    typedef impl_type * impl_ptr;
   23.68 +
   23.69 +    typedef BOOST_DEDUCED_TYPENAME coroutine_type
   23.70 +    ::result_type result_type;
   23.71 +
   23.72 +    typedef BOOST_DEDUCED_TYPENAME coroutine_type
   23.73 +    ::result_slot_type result_slot_type;
   23.74 +
   23.75 +    typedef BOOST_DEDUCED_TYPENAME coroutine_type
   23.76 +    ::yield_result_type yield_result_type;
   23.77 +
   23.78 +    typedef BOOST_DEDUCED_TYPENAME coroutine_type
   23.79 +    ::result_slot_traits result_slot_traits;
   23.80 +
   23.81 +    typedef BOOST_DEDUCED_TYPENAME coroutine_type
   23.82 +    ::arg_slot_type arg_slot_type;
   23.83 +
   23.84 +    typedef BOOST_DEDUCED_TYPENAME coroutine_type
   23.85 +    ::arg_slot_traits arg_slot_traits;
   23.86 +
   23.87 +    typedef BOOST_DEDUCED_TYPENAME coroutine_type
   23.88 +    ::yield_traits yield_traits;
   23.89 +#ifndef BOOST_COROUTINE_VCPP80_WORKAROUND 
   23.90 +#   define BOOST_COROUTINE_param_with_default(z, n, type_prefix)    \
   23.91 +    BOOST_DEDUCED_TYPENAME call_traits                              \
   23.92 +    <BOOST_PP_CAT(BOOST_PP_CAT(type_prefix, n), _type)>::param_type \
   23.93 +    BOOST_PP_CAT(arg, n) =                                          \
   23.94 +    BOOST_PP_CAT(BOOST_PP_CAT(type_prefix, n), _type)()             \
   23.95 +/**/
   23.96 +
   23.97 +    yield_result_type yield
   23.98 +    (BOOST_PP_ENUM
   23.99 +       (BOOST_COROUTINE_ARG_MAX,
  23.100 +	BOOST_COROUTINE_param_with_default,
  23.101 +	BOOST_DEDUCED_TYPENAME yield_traits::arg))
  23.102 +    {
  23.103 +      return yield_impl
  23.104 +	(BOOST_DEDUCED_TYPENAME 
  23.105 +	 coroutine_type::result_slot_type
  23.106 +	 (BOOST_PP_ENUM_PARAMS
  23.107 +	  (BOOST_COROUTINE_ARG_MAX, 
  23.108 +	   arg)));
  23.109 +    }
  23.110 +    
  23.111 +    template<typename Target>
  23.112 +    yield_result_type yield_to
  23.113 +    (Target& target
  23.114 +     BOOST_PP_ENUM_TRAILING
  23.115 +     (BOOST_COROUTINE_ARG_MAX,
  23.116 +      BOOST_COROUTINE_param_with_default,
  23.117 +      typename Target::arg)) 
  23.118 +    {
  23.119 +      typedef BOOST_DEDUCED_TYPENAME Target::arg_slot_type slot_type;
  23.120 +      return yield_to_impl
  23.121 +	(target, slot_type(BOOST_PP_ENUM_PARAMS
  23.122 +	  (BOOST_COROUTINE_ARG_MAX, 
  23.123 +	   arg)));
  23.124 +    }
  23.125 +#else
  23.126 +        
  23.127 +    /* 
  23.128 +     * VC8.0 can't handle the call_traits meta-invocation inside
  23.129 +     * a function parameter list (except when it does, see operator()). 
  23.130 +     * Splitting it in separate typedefs
  23.131 +     * fixes the problem.
  23.132 +     */
  23.133 +#define BOOST_COROUTINE_param_typedef(z, n, prefix_tuple)  \
  23.134 +    typedef BOOST_DEDUCED_TYPENAME                   \
  23.135 +    call_traits<                                     \
  23.136 +    BOOST_PP_CAT                                     \
  23.137 +    (BOOST_PP_CAT                                    \
  23.138 +     (BOOST_PP_TUPLE_ELEM(2, 0, prefix_tuple), n),   \
  23.139 +     _type)                                          \
  23.140 +      >::param_type                                  \
  23.141 +    BOOST_PP_CAT                                     \
  23.142 +    (BOOST_PP_CAT                                    \
  23.143 +     (BOOST_PP_TUPLE_ELEM(2, 1, prefix_tuple), n),   \
  23.144 +     _type)                                          \
  23.145 +     /**/;
  23.146 +    
  23.147 +    /*
  23.148 +     * Generate lines like this:
  23.149 +     * 'typedef typename call_traits<typename coroutine_type::yield_traits::argN_type>::param_type yield_call_argN_type;'
  23.150 +     */
  23.151 +    BOOST_PP_REPEAT(BOOST_COROUTINE_ARG_MAX, 
  23.152 +		    BOOST_COROUTINE_param_typedef, 
  23.153 +		    (BOOST_DEDUCED_TYPENAME 
  23.154 +		     coroutine_type::yield_traits::arg, yield_call_arg));
  23.155 +
  23.156 +    /*
  23.157 +     * Generate lines like this:
  23.158 +     * 'typedef typename call_traits<typename coroutine_type::argN_type>::param_type call_argN_type;'
  23.159 +     */
  23.160 +    BOOST_PP_REPEAT(BOOST_COROUTINE_ARG_MAX,
  23.161 +		    BOOST_COROUTINE_param_typedef,
  23.162 +		    (BOOST_DEDUCED_TYPENAME 
  23.163 +		     coroutine_type::arg, call_arg));
  23.164 +
  23.165 +#undef BOOST_COROUTINE_param_typedef
  23.166 +#undef  BOOST_COROUTINE_param_with_default
  23.167 +#define BOOST_COROUTINE_param_with_default(z, n, prefix_tuple) \
  23.168 +    BOOST_PP_CAT(BOOST_PP_CAT                                  \
  23.169 +		 (BOOST_PP_TUPLE_ELEM(2, 0, prefix_tuple),     \
  23.170 +		  n), _type)                                   \
  23.171 +      BOOST_PP_CAT(arg, n) =                                   \
  23.172 +    BOOST_PP_CAT(BOOST_PP_CAT                                  \
  23.173 +		 (BOOST_PP_TUPLE_ELEM(2, 1, prefix_tuple),     \
  23.174 +		  n), _type)()                                 \
  23.175 +      /**/
  23.176 +     
  23.177 +    yield_result_type yield
  23.178 +    (BOOST_PP_ENUM(BOOST_COROUTINE_ARG_MAX,
  23.179 +		   BOOST_COROUTINE_param_with_default,
  23.180 +		   (yield_call_arg ,
  23.181 +		    BOOST_COROUTINE_DEDUCED_TYPENAME_DEFAULT 
  23.182 +		    coroutine_type::yield_traits::arg))) 
  23.183 +    {
  23.184 +      return yield_impl
  23.185 +      (result_slot_type
  23.186 +       (BOOST_PP_ENUM_PARAMS(BOOST_COROUTINE_ARG_MAX,arg)));
  23.187 +    }
  23.188 +
  23.189 +    template<typename Target>
  23.190 +    yield_result_type yield_to
  23.191 +    (Target& target
  23.192 +     BOOST_PP_ENUM_TRAILING
  23.193 +     (BOOST_COROUTINE_ARG_MAX,
  23.194 +      BOOST_COROUTINE_param_with_default,
  23.195 +      (BOOST_DEDUCED_TYPENAME Target::self::call_arg, 
  23.196 +       BOOST_COROUTINE_DEDUCED_TYPENAME_DEFAULT Target::arg)))
  23.197 +    {
  23.198 +      typedef typename Target::arg_slot_type type;
  23.199 +      return yield_to_impl
  23.200 +	(target, type
  23.201 +	 (BOOST_PP_ENUM_PARAMS
  23.202 +	  (BOOST_COROUTINE_ARG_MAX, arg)));
  23.203 +    }
  23.204 +#endif
  23.205 +
  23.206 +#undef  BOOST_COROUTINE_param_with_default
  23.207 +
  23.208 +    BOOST_COROUTINE_NORETURN(void exit()) {
  23.209 +      m_pimpl -> exit_self();
  23.210 +      abort();
  23.211 +    }
  23.212 +
  23.213 +    yield_result_type result() {
  23.214 +      return detail::fix_result<
  23.215 +	BOOST_DEDUCED_TYPENAME
  23.216 +	coroutine_type::arg_slot_traits>(*m_pimpl->args());
  23.217 +    }
  23.218 +
  23.219 +    bool pending() const {
  23.220 +      BOOST_ASSERT(m_pimpl);
  23.221 +      return m_pimpl->pending();
  23.222 +    }
  23.223 +
  23.224 +    /// @c true only if this @c self object was created by the passed @a coroutine
  23.225 +    template <typename SomeCoroutine>
  23.226 +    bool is_from(const SomeCoroutine& coroutine) const
  23.227 +    {
  23.228 +      // get_impl() only accepts non-const ref... a mistake, IMO.
  23.229 +      return static_cast<void*>(coroutine_accessor::get_impl(const_cast<SomeCoroutine&>(coroutine)).get()) ==
  23.230 +             static_cast<void*>(m_pimpl);
  23.231 +    }
  23.232 +
  23.233 +    /// opaque token used to correlate this 'self' with its corresponding coroutine
  23.234 +    void* get_id() const { return m_pimpl; }
  23.235 +
  23.236 +  private:
  23.237 +    coroutine_self(impl_type * pimpl, detail::init_from_impl_tag) :
  23.238 +      m_pimpl(pimpl) {}
  23.239 +
  23.240 +    yield_result_type yield_impl(BOOST_DEDUCED_TYPENAME 
  23.241 +				 coroutine_type::result_slot_type result) {
  23.242 +      typedef BOOST_DEDUCED_TYPENAME
  23.243 +	coroutine_type::result_slot_type slot_type;
  23.244 +
  23.245 +      BOOST_ASSERT(m_pimpl);
  23.246 +
  23.247 +      this->m_pimpl->bind_result(&result);
  23.248 +      this->m_pimpl->yield();    
  23.249 +      return detail::fix_result<
  23.250 +	BOOST_DEDUCED_TYPENAME
  23.251 +	coroutine_type::arg_slot_traits>(*m_pimpl->args());
  23.252 +    }
  23.253 +
  23.254 +    template<typename TargetCoroutine>
  23.255 +    yield_result_type yield_to_impl(TargetCoroutine& target, 
  23.256 +			   BOOST_DEDUCED_TYPENAME TargetCoroutine
  23.257 +			   ::arg_slot_type args) {
  23.258 +      BOOST_ASSERT(m_pimpl);
  23.259 +
  23.260 +      coroutine_accessor::get_impl(target)->bind_args(&args);
  23.261 +      coroutine_accessor::get_impl(target)->bind_result_pointer(m_pimpl->result_pointer());    
  23.262 +
  23.263 +      this->m_pimpl->yield_to(*coroutine_accessor::get_impl(target));
  23.264 +
  23.265 +      return detail::fix_result<
  23.266 +	BOOST_DEDUCED_TYPENAME
  23.267 +	coroutine_type::arg_slot_traits>(*m_pimpl->args());
  23.268 +    }
  23.269 +
  23.270 +    impl_ptr get_impl() {
  23.271 +      return m_pimpl;
  23.272 +    }
  23.273 +    impl_ptr m_pimpl;
  23.274 +  };
  23.275 +} } }
  23.276 +
  23.277 +#endif
    24.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    24.2 +++ b/boost_1_45_0/boost/coroutine/detail/signal.hpp	Fri Mar 04 12:51:59 2011 -0800
    24.3 @@ -0,0 +1,67 @@
    24.4 +//  Copyright (c) 2006, Giovanni P. Deretta
    24.5 +//
    24.6 +//  This code may be used under either of the following two licences:
    24.7 +//
    24.8 +//  Permission is hereby granted, free of charge, to any person obtaining a copy 
    24.9 +//  of this software and associated documentation files (the "Software"), to deal 
   24.10 +//  in the Software without restriction, including without limitation the rights 
   24.11 +//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 
   24.12 +//  copies of the Software, and to permit persons to whom the Software is 
   24.13 +//  furnished to do so, subject to the following conditions:
   24.14 +//
   24.15 +//  The above copyright notice and this permission notice shall be included in 
   24.16 +//  all copies or substantial portions of the Software.
   24.17 +//
   24.18 +//  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
   24.19 +//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
   24.20 +//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
   24.21 +//  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
   24.22 +//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
   24.23 +//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 
   24.24 +//  THE SOFTWARE. OF SUCH DAMAGE.
   24.25 +//
   24.26 +//  Or:
   24.27 +//
   24.28 +//  Distributed under the Boost Software License, Version 1.0.
   24.29 +//  (See accompanying file LICENSE_1_0.txt or copy at
   24.30 +//  http://www.boost.org/LICENSE_1_0.txt)
   24.31 +
   24.32 +#ifndef BOOST_COROUTINE_DETAIL_SIGNAL_HPP_20060728
   24.33 +#define BOOST_COROUTINE_DETAIL_SIGNAL_HPP_20060728
   24.34 +#include <boost/coroutine/detail/future_impl.hpp>
   24.35 +namespace boost { namespace coroutines { namespace detail {
   24.36 +  /*
   24.37 +   * Private interface for coroutine signaling/waiting.
   24.38 +   * These class is friend of future_impl and
   24.39 +   * its static members are invoked by asynchronous callback functions.
   24.40 +   */
   24.41 +  struct wait_gateway {
   24.42 +    template<typename Future>
   24.43 +    static void wait(Future& f, int n) {
   24.44 +      f.wait(n);
   24.45 +    }
   24.46 +
   24.47 +    template<typename Future>
   24.48 +    static 
   24.49 +    bool waited(const Future& f) {
   24.50 +      return f.waited();
   24.51 +    }
   24.52 +
   24.53 +    template<typename Future>
   24.54 +    static 
   24.55 +    void mark_wait(Future& f, bool how) {
   24.56 +      f.mark_wait(how);
   24.57 +    }
   24.58 +
   24.59 +    template<typename Future>
   24.60 +    static
   24.61 +    BOOST_DEDUCED_TYPENAME 
   24.62 +    Future::impl_pointer
   24.63 +    get_impl(Future& f) {
   24.64 +      return f.m_ptr;
   24.65 +    }
   24.66 +  };
   24.67 +
   24.68 +
   24.69 +} } }
   24.70 +#endif
    25.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    25.2 +++ b/boost_1_45_0/boost/coroutine/detail/signature.hpp	Fri Mar 04 12:51:59 2011 -0800
    25.3 @@ -0,0 +1,56 @@
    25.4 +//  Copyright (c) 2006, Giovanni P. Deretta
    25.5 +//
    25.6 +//  This code may be used under either of the following two licences:
    25.7 +//
    25.8 +//  Permission is hereby granted, free of charge, to any person obtaining a copy 
    25.9 +//  of this software and associated documentation files (the "Software"), to deal 
   25.10 +//  in the Software without restriction, including without limitation the rights 
   25.11 +//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 
   25.12 +//  copies of the Software, and to permit persons to whom the Software is 
   25.13 +//  furnished to do so, subject to the following conditions:
   25.14 +//
   25.15 +//  The above copyright notice and this permission notice shall be included in 
   25.16 +//  all copies or substantial portions of the Software.
   25.17 +//
   25.18 +//  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
   25.19 +//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
   25.20 +//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
   25.21 +//  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
   25.22 +//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
   25.23 +//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 
   25.24 +//  THE SOFTWARE. OF SUCH DAMAGE.
   25.25 +//
   25.26 +//  Or:
   25.27 +//
   25.28 +//  Distributed under the Boost Software License, Version 1.0.
   25.29 +//  (See accompanying file LICENSE_1_0.txt or copy at
   25.30 +//  http://www.boost.org/LICENSE_1_0.txt)
   25.31 +
   25.32 +#ifndef BOOST_COROUTINE_DETAIL_SIGNATURE_HPP_20060609
   25.33 +#define BOOST_COROUTINE_DETAIL_SIGNATURE_HPP_20060609
   25.34 +#include <boost/preprocessor/repetition.hpp>
   25.35 +#include <boost/coroutine/detail/arg_max.hpp>
   25.36 +namespace boost{ namespace coroutines{ namespace detail{
   25.37 +  /*
   25.38 +   * Derived from an  mpl::vector describing
   25.39 +   * 'Function' arguments types.
   25.40 +   */
   25.41 +  template<typename Function>
   25.42 +  struct signature;
   25.43 +
   25.44 +  /*
   25.45 +   * Generate specializations for the signature trait class.
   25.46 +   */
   25.47 +#define BOOST_COROUTINE_SIGNATURE_GENERATOR(z, n, unused)        \
   25.48 +  template <class R BOOST_PP_ENUM_TRAILING_PARAMS(n, class A)>   \
   25.49 +  struct signature<R( BOOST_PP_ENUM_PARAMS(n,A) ) >              \
   25.50 +    : boost::mpl::BOOST_PP_CAT(vector,n)<                        \
   25.51 +    BOOST_PP_ENUM_PARAMS(n,A)                                    \
   25.52 +    > {};                                                        \
   25.53 +/**/
   25.54 +
   25.55 +  
   25.56 +  BOOST_PP_REPEAT(BOOST_COROUTINE_ARG_MAX, BOOST_COROUTINE_SIGNATURE_GENERATOR, ~);
   25.57 +#undef BOOST_COROUTINE_SIGNATURE_GENERATOR
   25.58 +} } }
   25.59 +#endif
    26.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    26.2 +++ b/boost_1_45_0/boost/coroutine/detail/swap_context.hpp	Fri Mar 04 12:51:59 2011 -0800
    26.3 @@ -0,0 +1,38 @@
    26.4 +//  Copyright (c) 2006, Giovanni P. Deretta
    26.5 +//
    26.6 +//  This code may be used under either of the following two licences:
    26.7 +//
    26.8 +//  Permission is hereby granted, free of charge, to any person obtaining a copy 
    26.9 +//  of this software and associated documentation files (the "Software"), to deal 
   26.10 +//  in the Software without restriction, including without limitation the rights 
   26.11 +//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 
   26.12 +//  copies of the Software, and to permit persons to whom the Software is 
   26.13 +//  furnished to do so, subject to the following conditions:
   26.14 +//
   26.15 +//  The above copyright notice and this permission notice shall be included in 
   26.16 +//  all copies or substantial portions of the Software.
   26.17 +//
   26.18 +//  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
   26.19 +//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
   26.20 +//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
   26.21 +//  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
   26.22 +//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
   26.23 +//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 
   26.24 +//  THE SOFTWARE. OF SUCH DAMAGE.
   26.25 +//
   26.26 +//  Or:
   26.27 +//
   26.28 +//  Distributed under the Boost Software License, Version 1.0.
   26.29 +//  (See accompanying file LICENSE_1_0.txt or copy at
   26.30 +//  http://www.boost.org/LICENSE_1_0.txt)
   26.31 +
   26.32 +#ifndef BOOST_COROUTINE_SWAP_CONTEXT_HPP_20060611
   26.33 +#define BOOST_COROUTINE_SWAP_CONTEXT_HPP_20060611
   26.34 +namespace boost{ namespace coroutines { namespace detail {
   26.35 +  class default_hint {};
   26.36 +  class yield_hint: public default_hint {};
   26.37 +  class yield_to_hint: public default_hint {};
   26.38 +  class invoke_hint: public default_hint {};
   26.39 +  
   26.40 +} } }
   26.41 +#endif
    27.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    27.2 +++ b/boost_1_45_0/boost/coroutine/detail/wait_impl.hpp	Fri Mar 04 12:51:59 2011 -0800
    27.3 @@ -0,0 +1,102 @@
    27.4 +//  Copyright (c) 2006, Giovanni P. Deretta
    27.5 +//
    27.6 +//  This code may be used under either of the following two licences:
    27.7 +//
    27.8 +//  Permission is hereby granted, free of charge, to any person obtaining a copy 
    27.9 +//  of this software and associated documentation files (the "Software"), to deal 
   27.10 +//  in the Software without restriction, including without limitation the rights 
   27.11 +//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 
   27.12 +//  copies of the Software, and to permit persons to whom the Software is 
   27.13 +//  furnished to do so, subject to the following conditions:
   27.14 +//
   27.15 +//  The above copyright notice and this permission notice shall be included in 
   27.16 +//  all copies or substantial portions of the Software.
   27.17 +//
   27.18 +//  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
   27.19 +//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
   27.20 +//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
   27.21 +//  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
   27.22 +//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
   27.23 +//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 
   27.24 +//  THE SOFTWARE. OF SUCH DAMAGE.
   27.25 +//
   27.26 +//  Or:
   27.27 +//
   27.28 +//  Distributed under the Boost Software License, Version 1.0.
   27.29 +//  (See accompanying file LICENSE_1_0.txt or copy at
   27.30 +//  http://www.boost.org/LICENSE_1_0.txt)
   27.31 +
   27.32 +
   27.33 +#ifndef BOOST_COROUTINE_DETAIL_WAIT_IMPL_HPP_20060728
   27.34 +#define BOOST_COROUTINE_DETAIL_WAIT_IMPL_HPP_20060728
   27.35 +#include <boost/tuple/tuple.hpp>
   27.36 +#include <boost/coroutine/detail/signal.hpp>
   27.37 +namespace boost { namespace coroutines { namespace detail {
   27.38 +
   27.39 +  /*
   27.40 +   * Inokes mark_wait('how') on the 'Idx'th element of 't'
   27.41 +   * then calls marker::wait<Idx-1> with the same arguments.
   27.42 +   * returns the result of marker::wait<Idx-1>(...) plus 1 if
   27.43 +   * the 'Idx'th.pending() is true or plus 0 otherwise.
   27.44 +   * 
   27.45 +   */
   27.46 +  template<int Idx>
   27.47 +  struct marker {
   27.48 +    template<typename Tuple>
   27.49 +    static int mark(Tuple& t, bool how) {
   27.50 +      wait_gateway::mark_wait(t.template get<Idx-1>(), how);
   27.51 +      return marker<Idx -1>::mark(t, how) + (t.template get<Idx-1>().pending()? 1:0);
   27.52 +
   27.53 +    }
   27.54 +  };
   27.55 +
   27.56 +  /* Recursion terminator */
   27.57 +  template<>
   27.58 +  struct marker<0> {
   27.59 +    template<typename Tuple>
   27.60 +    static int mark(Tuple&, bool) { return 0;}
   27.61 +  };
   27.62 +
   27.63 +  template<typename Tuple>
   27.64 +  void wait_n(const Tuple& t, int n) {
   27.65 +    BOOST_STATIC_ASSERT(boost::tuples::length<Tuple>::value);
   27.66 +    wait_gateway::wait(t.get<0>(), n);
   27.67 +  }
   27.68 +
   27.69 +  /*
   27.70 +   * Wait for at least one future in 'wt' tuple to be signaled.
   27.71 +   * If at least one future has been already signaled do not
   27.72 +   * block but returns immediatley (prevents deadlocks).
   27.73 +   */
   27.74 +  template<typename Tuple>
   27.75 +  void wait_impl(Tuple wt) {
   27.76 +    try {
   27.77 +      if(marker<boost::tuples::length<Tuple>::value>::mark(wt, true) > 0) 
   27.78 +	wait_n(wt, 1);
   27.79 +    } catch (...) {
   27.80 +      marker<boost::tuples::length<Tuple>::value>::mark(wt, false);
   27.81 +      throw;
   27.82 +    }
   27.83 +    int res = marker<boost::tuples::length<Tuple>::value>::mark(wt, false);
   27.84 +    BOOST_ASSERT(res < boost::tuples::length<Tuple>::value);
   27.85 +    (void)res;
   27.86 +  }
   27.87 +
   27.88 +  /*
   27.89 +   * Wait for all futures in 'wt' tuple to be signaled.
   27.90 +   */
   27.91 +  template<typename Tuple>
   27.92 +  void wait_all_impl(Tuple wt) {
   27.93 +    int res = marker<boost::tuples::length<Tuple>::value>::mark(wt, true);
   27.94 +    try {
   27.95 +      wait_n(wt, res);
   27.96 +    } catch (...) {
   27.97 +      marker<boost::tuples::length<Tuple>::value>::mark(wt, false);
   27.98 +      throw;
   27.99 +    }
  27.100 +    res = marker<boost::tuples::length<Tuple>::value>::mark(wt, false);
  27.101 +    BOOST_ASSERT(res == 0);
  27.102 +  }
  27.103 +
  27.104 +} } }
  27.105 +#endif
    28.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    28.2 +++ b/boost_1_45_0/boost/coroutine/detail/yield_result_type.hpp	Fri Mar 04 12:51:59 2011 -0800
    28.3 @@ -0,0 +1,54 @@
    28.4 +//  Copyright (c) 2006, Giovanni P. Deretta
    28.5 +//
    28.6 +//  This code may be used under either of the following two licences:
    28.7 +//
    28.8 +//  Permission is hereby granted, free of charge, to any person obtaining a copy 
    28.9 +//  of this software and associated documentation files (the "Software"), to deal 
   28.10 +//  in the Software without restriction, including without limitation the rights 
   28.11 +//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 
   28.12 +//  copies of the Software, and to permit persons to whom the Software is 
   28.13 +//  furnished to do so, subject to the following conditions:
   28.14 +//
   28.15 +//  The above copyright notice and this permission notice shall be included in 
   28.16 +//  all copies or substantial portions of the Software.
   28.17 +//
   28.18 +//  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
   28.19 +//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
   28.20 +//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
   28.21 +//  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
   28.22 +//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
   28.23 +//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 
   28.24 +//  THE SOFTWARE. OF SUCH DAMAGE.
   28.25 +//
   28.26 +//  Or:
   28.27 +//
   28.28 +//  Distributed under the Boost Software License, Version 1.0.
   28.29 +//  (See accompanying file LICENSE_1_0.txt or copy at
   28.30 +//  http://www.boost.org/LICENSE_1_0.txt)
   28.31 +
   28.32 +#ifndef BOOST_COROUTINE_DETAIL_YIELD_RESULT_TYPE_HPP_20060609
   28.33 +#define BOOST_COROUTINE_DETAIL_YIELD_RESULT_TYPE_HPP_20060609
   28.34 +#include <boost/coroutine/detail/make_tuple_traits.hpp>
   28.35 +#include <boost/mpl/vector.hpp>
   28.36 +namespace boost{ namespace coroutines { namespace detail {
   28.37 +    /**
   28.38 +     * Same as make_tuple_traits, but if
   28.39 +     * @p TypeList is singular, @p type is the single element, and
   28.40 +     * if TypeList is empty, @p type is @p void.
   28.41 +     */
   28.42 +    template<typename TypeList>
   28.43 +    struct yield_result_type {
   28.44 +      typedef typename make_tuple_traits<TypeList>::type type;
   28.45 +    };
   28.46 +    
   28.47 +    template<typename T>
   28.48 +    struct yield_result_type <boost::mpl::vector1<T> >{
   28.49 +      typedef T type;
   28.50 +    };
   28.51 +    
   28.52 +    template<>
   28.53 +    struct yield_result_type <boost::mpl::vector0<> >{
   28.54 +      typedef void type;
   28.55 +    };
   28.56 +} } }
   28.57 +#endif
    29.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    29.2 +++ b/boost_1_45_0/boost/coroutine/exception.hpp	Fri Mar 04 12:51:59 2011 -0800
    29.3 @@ -0,0 +1,80 @@
    29.4 +//  Copyright (c) 2006, Giovanni P. Deretta
    29.5 +//
    29.6 +//  This code may be used under either of the following two licences:
    29.7 +//
    29.8 +//  Permission is hereby granted, free of charge, to any person obtaining a copy 
    29.9 +//  of this software and associated documentation files (the "Software"), to deal 
   29.10 +//  in the Software without restriction, including without limitation the rights 
   29.11 +//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 
   29.12 +//  copies of the Software, and to permit persons to whom the Software is 
   29.13 +//  furnished to do so, subject to the following conditions:
   29.14 +//
   29.15 +//  The above copyright notice and this permission notice shall be included in 
   29.16 +//  all copies or substantial portions of the Software.
   29.17 +//
   29.18 +//  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
   29.19 +//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
   29.20 +//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
   29.21 +//  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
   29.22 +//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
   29.23 +//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 
   29.24 +//  THE SOFTWARE. OF SUCH DAMAGE.
   29.25 +//
   29.26 +//  Or:
   29.27 +//
   29.28 +//  Distributed under the Boost Software License, Version 1.0.
   29.29 +//  (See accompanying file LICENSE_1_0.txt or copy at
   29.30 +//  http://www.boost.org/LICENSE_1_0.txt)
   29.31 +
   29.32 +#ifndef BOOST_COROUTINE_EXCEPTION_HPP_20060601
   29.33 +#define BOOST_COROUTINE_EXCEPTION_HPP_20060601
   29.34 +#include <exception>
   29.35 +#include <typeinfo>
   29.36 +namespace boost { namespace coroutines {
   29.37 +
   29.38 +  // All coroutine exceptions are derived from this base.
   29.39 +  class exception_base : public std::exception {};
   29.40 +
   29.41 +  // This exception is thrown when a coroutine is requested
   29.42 +  // to exit.
   29.43 +  class exit_exception:  public exception_base {};
   29.44 +
   29.45 +  // This exception is thrown on a coroutine invocation
   29.46 +  // if a coroutine exits without
   29.47 +  // returning a result. Note that calling invoke()
   29.48 +  // on an already exited coroutine is undefined behaviour.
   29.49 +  class coroutine_exited: public exception_base {};  
   29.50 +  
   29.51 +  // This exception is thrown on a coroutine invocation
   29.52 +  // if a coroutine enter the wait state without
   29.53 +  // returning a result. Note that calling invoke()
   29.54 +  // on a waiting coroutine is undefined behaviour.
   29.55 +  class waiting : public exception_base {};
   29.56 +
   29.57 +  class unknown_exception_tag {};
   29.58 +
   29.59 +  // This exception is thrown on a coroutine invocation
   29.60 +  // if the coroutine is exited by an uncatched exception
   29.61 +  // (not derived from exit_exception). abnormal_exit::type()
   29.62 +  // returns the typeid of that exception if it is derived
   29.63 +  // from std::exception, else returns typeid(unknonw_exception_tag)
   29.64 +  class abnormal_exit : public std::exception {
   29.65 +  public:
   29.66 +    abnormal_exit(std::type_info const& e) :
   29.67 +      m_e (e) {};
   29.68 +
   29.69 +    const char* what() const throw() {
   29.70 +      return m_e == typeid(unknown_exception_tag)? 
   29.71 +	"unknown exception" :
   29.72 +	m_e.name();
   29.73 +    }
   29.74 +
   29.75 +    std::type_info const& type() const throw() {
   29.76 +      return m_e;
   29.77 +    }
   29.78 +  private:
   29.79 +    std::type_info const& m_e;
   29.80 +  };
   29.81 +} } 
   29.82 +
   29.83 +#endif
    30.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    30.2 +++ b/boost_1_45_0/boost/coroutine/future.hpp	Fri Mar 04 12:51:59 2011 -0800
    30.3 @@ -0,0 +1,305 @@
    30.4 +//  Copyright (c) 2006, Giovanni P. Deretta
    30.5 +//
    30.6 +//  This code may be used under either of the following two licences:
    30.7 +//
    30.8 +//  Permission is hereby granted, free of charge, to any person obtaining a copy 
    30.9 +//  of this software and associated documentation files (the "Software"), to deal 
   30.10 +//  in the Software without restriction, including without limitation the rights 
   30.11 +//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 
   30.12 +//  copies of the Software, and to permit persons to whom the Software is 
   30.13 +//  furnished to do so, subject to the following conditions:
   30.14 +//
   30.15 +//  The above copyright notice and this permission notice shall be included in 
   30.16 +//  all copies or substantial portions of the Software.
   30.17 +//
   30.18 +//  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
   30.19 +//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
   30.20 +//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
   30.21 +//  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
   30.22 +//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
   30.23 +//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 
   30.24 +//  THE SOFTWARE. OF SUCH DAMAGE.
   30.25 +//
   30.26 +//  Or:
   30.27 +//
   30.28 +//  Distributed under the Boost Software License, Version 1.0.
   30.29 +//  (See accompanying file LICENSE_1_0.txt or copy at
   30.30 +//  http://www.boost.org/LICENSE_1_0.txt)
   30.31 +
   30.32 +#ifndef BOOST_COROUTINE_FUTURE_HPP_20060728
   30.33 +#define BOOST_COROUTINE_FUTURE_HPP_20060728
   30.34 +
   30.35 +// Max number of futures that can be waited for.
   30.36 +#ifndef BOOST_COROUTINE_WAIT_MAX
   30.37 +#define BOOST_COROUTINE_WAIT_MAX 10
   30.38 +#endif
   30.39 +// On Linux systems, use native swapcontext() et al. rather than
   30.40 +// Boost.Coroutine homebrew assembler
   30.41 +#define BOOST_COROUTINE_NO_ASM
   30.42 +// default_context_impl.hpp must be first for weird Apple bug
   30.43 +#include <boost/coroutine/detail/default_context_impl.hpp>
   30.44 +#include <boost/none.hpp>
   30.45 +#include <boost/config.hpp>
   30.46 +#include <boost/tuple/tuple.hpp>
   30.47 +#include <boost/mpl/eval_if.hpp>
   30.48 +#include <boost/mpl/identity.hpp>
   30.49 +#include <boost/preprocessor/repetition.hpp>
   30.50 +#include <boost/preprocessor/facilities/intercept.hpp>
   30.51 +
   30.52 +#include <boost/coroutine/move.hpp>
   30.53 +#include <boost/coroutine/tuple_traits.hpp>
   30.54 +#include <boost/coroutine/detail/signal.hpp>
   30.55 +#include <boost/coroutine/detail/arg_max.hpp>
   30.56 +#include <boost/coroutine/detail/call_impl.hpp>
   30.57 +#include <boost/coroutine/detail/wait_impl.hpp>
   30.58 +#include <boost/coroutine/detail/future_impl.hpp>
   30.59 +
   30.60 +namespace boost { namespace coroutines {
   30.61 +
   30.62 +  template<
   30.63 +    BOOST_PP_ENUM_BINARY_PARAMS
   30.64 +  (BOOST_COROUTINE_ARG_MAX,
   30.65 +   typename T, 
   30.66 +   = boost::tuples::null_type BOOST_PP_INTERCEPT),
   30.67 +    typename ContextImpl = detail::default_context_impl 
   30.68 +    >
   30.69 +  class future : 
   30.70 +    public movable
   30.71 +  <future<BOOST_PP_ENUM_PARAMS(BOOST_COROUTINE_ARG_MAX, T)> > 
   30.72 +  {
   30.73 +
   30.74 +    friend struct detail::wait_gateway;
   30.75 +    typedef void (future::*safe_bool)();           
   30.76 +    void safe_bool_true() {}                       
   30.77 +
   30.78 +  public:
   30.79 +    typedef ContextImpl context_impl;
   30.80 +
   30.81 +    typedef tuple_traits<
   30.82 +      BOOST_PP_ENUM_PARAMS
   30.83 +      (BOOST_COROUTINE_ARG_MAX, T)
   30.84 +      > tuple_traits_type;
   30.85 +
   30.86 +    typedef boost::mpl::bool_<tuple_traits_type::length == 1>
   30.87 +      is_singular;
   30.88 +   
   30.89 +    typedef BOOST_DEDUCED_TYPENAME tuple_traits_type::as_tuple tuple_type;
   30.90 +    typedef BOOST_DEDUCED_TYPENAME boost::mpl::eval_if<
   30.91 +      boost::mpl::not_<is_singular>,
   30.92 +      boost::mpl::identity<tuple_type>,
   30.93 +      BOOST_DEDUCED_TYPENAME tuple_traits_type::template at<0>
   30.94 +      >::type  value_type;
   30.95 +   
   30.96 +    typedef detail::future_impl<tuple_type, context_impl> future_impl;
   30.97 +    typedef future_impl * impl_pointer;
   30.98 +    template<typename CoroutineSelf>
   30.99 +      future(CoroutineSelf& self) :
  30.100 +      m_ptr(new future_impl(self)) {}
  30.101 +   
  30.102 +    future(move_from<future> rhs) :
  30.103 +      m_ptr(rhs->pilfer()) {}
  30.104 +
  30.105 +   
  30.106 +    value_type& operator *() {
  30.107 +      BOOST_ASSERT(m_ptr);
  30.108 +      wait();
  30.109 +      return remove_tuple(m_ptr->value(),  boost::mpl::not_<is_singular>());
  30.110 +    }
  30.111 +
  30.112 +    const value_type& operator *() const{
  30.113 +      BOOST_ASSERT(m_ptr);
  30.114 +      BOOST_ASSERT(m_ptr->get());
  30.115 +      wait();
  30.116 +      return remove_tuple(m_ptr->value(), boost::mpl::not_<is_singular>());
  30.117 +    }
  30.118 +   
  30.119 +    future& operator=(move_from<future> rhs) {
  30.120 +      future(rhs).swap(*this);
  30.121 +      return *this;
  30.122 +    }
  30.123 +
  30.124 +    future& operator=(const value_type& rhs) {
  30.125 +      BOOST_ASSERT(!pending());
  30.126 +      m_ptr->get() = tuple_type(rhs);
  30.127 +      return *this;
  30.128 +    }
  30.129 +
  30.130 +    future& operator=(none_t) {
  30.131 +      BOOST_ASSERT(!pending());
  30.132 +      m_ptr->get() = none;
  30.133 +      return *this;
  30.134 +    }
  30.135 +
  30.136 +    operator safe_bool() const {    
  30.137 +      BOOST_ASSERT(m_ptr);
  30.138 +      return m_ptr->get()?                     
  30.139 +	&future::safe_bool_true: 0;                 
  30.140 +    }       
  30.141 +
  30.142 +    BOOST_DEDUCED_TYPENAME
  30.143 +      future_impl::pointer & 
  30.144 +      operator ->() {
  30.145 +      BOOST_ASSERT(m_ptr);
  30.146 +      wait();
  30.147 +      return m_ptr->get();
  30.148 +    }
  30.149 +
  30.150 +    BOOST_DEDUCED_TYPENAME
  30.151 +      future_impl::pointer const 
  30.152 +      operator ->() const {
  30.153 +      BOOST_ASSERT(m_ptr);
  30.154 +      wait();
  30.155 +      return m_ptr->get();
  30.156 +    }
  30.157 +
  30.158 +    friend void swap(future& lhs, future& rhs) {
  30.159 +      std::swap(lhs.m_ptr, rhs.m_ptr);
  30.160 +    }
  30.161 +
  30.162 +    // On destruction, if the future is 
  30.163 +    // pending it will be destroyed.
  30.164 +    ~future() {
  30.165 +      if(m_ptr) {
  30.166 +	wait();
  30.167 +      	delete m_ptr;
  30.168 +      }
  30.169 +    }
  30.170 +
  30.171 +    // Return true if an async call has
  30.172 +    // been scheduled for this future.
  30.173 +    bool pending() const {
  30.174 +      BOOST_ASSERT(m_ptr);
  30.175 +      return m_ptr->pending();
  30.176 +    }
  30.177 +
  30.178 +  private:
  30.179 +    void wait(int n) {
  30.180 +      m_ptr->wait(n);
  30.181 +    }
  30.182 +
  30.183 +    void wait() {
  30.184 +      m_ptr->wait();
  30.185 +    }
  30.186 +
  30.187 +    template<typename T>
  30.188 +      value_type& remove_tuple(T& x, boost::mpl::false_) {
  30.189 +      return boost::get<0>(x);
  30.190 +    }
  30.191 +
  30.192 +    template<typename T>
  30.193 +      value_type& remove_tuple(T& x, boost::mpl::true_) {
  30.194 +      return x;
  30.195 +    }
  30.196 +
  30.197 +    void mark_wait(bool how) {
  30.198 +      BOOST_ASSERT(m_ptr);
  30.199 +      m_ptr->mark_wait(how);
  30.200 +    }
  30.201 +
  30.202 +    bool waited() const {
  30.203 +      BOOST_ASSERT(m_ptr);
  30.204 +      return m_ptr->waited();
  30.205 +    }
  30.206 +
  30.207 +    impl_pointer pilfer() {
  30.208 +      impl_pointer ptr = m_ptr;
  30.209 +      m_ptr = 0;
  30.210 +      return ptr;
  30.211 +    }
  30.212 +
  30.213 +    impl_pointer m_ptr;    
  30.214 +  };
  30.215 +
  30.216 +#define BOOST_COROUTINE_gen_call_overload(z, n, unused) \
  30.217 +  template<                                             \
  30.218 +    BOOST_PP_ENUM_PARAMS(n, typename T)                 \
  30.219 +    BOOST_PP_COMMA_IF(n)                                \
  30.220 +    typename Functor,                                   \
  30.221 +    typename Coroutine>                                 \
  30.222 +  future<BOOST_PP_ENUM_PARAMS(n, T)>                    \
  30.223 +  call(const Functor f, const Coroutine& coro) {        \
  30.224 +    return detail::call_impl<future<BOOST_PP_ENUM_PARAMS (n,T)> >(f, coro);  \
  30.225 +  }                                                     \
  30.226 +/**/
  30.227 +
  30.228 +  /*
  30.229 +   * Generate overloads of call<...>(function, coroutine) for
  30.230 +   * an arbitrary argument numbers that will forward to 
  30.231 +   * detail::call_impl<future<...> >(function, coroutine)
  30.232 +   */
  30.233 +  BOOST_PP_REPEAT(BOOST_COROUTINE_ARG_MAX,
  30.234 +		  BOOST_COROUTINE_gen_call_overload,
  30.235 +		  ~);
  30.236 +    
  30.237 +#define BOOST_COROUTINE_empty(z, n, name) \
  30.238 +/**/
  30.239 +
  30.240 +#define BOOST_COROUTINE_gen_reference(z, n, unused) \
  30.241 +    BOOST_PP_CAT(T, n) &                            \
  30.242 +/**/
  30.243 +
  30.244 +#define BOOST_COROUTINE_gen_wait_non_zero(z, n, name)\
  30.245 +  template<BOOST_PP_ENUM_PARAMS(n, typename T)>      \
  30.246 +  void name (BOOST_PP_ENUM_BINARY_PARAMS(n, T, &arg)) {  \
  30.247 +    detail::BOOST_PP_CAT(name, _impl)                \
  30.248 +      (boost::tuple<BOOST_PP_ENUM(n, BOOST_COROUTINE_gen_reference, ~)> \
  30.249 +       (BOOST_PP_ENUM_PARAMS(n, arg)));              \
  30.250 +  }                                                  \
  30.251 +/**/
  30.252 +
  30.253 +#define BOOST_COROUTINE_gen_wait(z, n, name)     \
  30.254 +  BOOST_PP_IF(n,                                 \
  30.255 +	      BOOST_COROUTINE_gen_wait_non_zero, \
  30.256 +	      BOOST_COROUTINE_empty)(z, n, name) \
  30.257 +/**/
  30.258 +
  30.259 +  /*
  30.260 +   * Generate overloads of wait(coro, ...) for
  30.261 +   * an arbitrary argument number that will
  30.262 +   * forward to detail::wait_impl(coro, tuple<...>)
  30.263 +   */
  30.264 +  BOOST_PP_REPEAT(BOOST_COROUTINE_WAIT_MAX,
  30.265 +		  BOOST_COROUTINE_gen_wait,
  30.266 +		  wait);
  30.267 +
  30.268 +  /*
  30.269 +   * Generate wait_all(coro, ...) for an arbitrary arguement
  30.270 +   * number that will forward to
  30.271 +   * detail::wait_all_impl(coro, tuple<...>)
  30.272 +   */
  30.273 +  BOOST_PP_REPEAT(BOOST_COROUTINE_WAIT_MAX,
  30.274 +		  BOOST_COROUTINE_gen_wait,
  30.275 +		  wait_all);
  30.276 +
  30.277 +#undef BOOST_COROUTINE_gen_wait
  30.278 +#undef BOOST_COROUTINE_empty
  30.279 +#undef BOOST_COROUTINE_gen_reference
  30.280 +#undef BOOST_COROUTINE_gen_wait_non_zero
  30.281 +#undef BOOST_COROUTINE_gen_call_overload
  30.282 +
  30.283 +  template<typename Future >
  30.284 +  struct make_callback_result {
  30.285 +    typedef detail::callback<Future> type;
  30.286 +  };
  30.287 +
  30.288 +  /*
  30.289 +   * Returns a callback object that when invoked
  30.290 +   * will signal the associated coroutine::self object.
  30.291 +   * It will extend the lifetime of the object until
  30.292 +   * it is signaled. More than one callback object
  30.293 +   * can be pending at any time. The coroutine self
  30.294 +   * will last at least untill the last pending callback 
  30.295 +   * is fired.
  30.296 +   */
  30.297 +  template<typename Future>
  30.298 +  BOOST_DEDUCED_TYPENAME 
  30.299 +  make_callback_result<Future>
  30.300 +  ::type
  30.301 +  make_callback(Future& future) {
  30.302 +    return BOOST_DEDUCED_TYPENAME make_callback_result<Future>::type
  30.303 +      (future);
  30.304 +  }
  30.305 +
  30.306 +} } 
  30.307 +#endif
  30.308 +
    31.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    31.2 +++ b/boost_1_45_0/boost/coroutine/generator.hpp	Fri Mar 04 12:51:59 2011 -0800
    31.3 @@ -0,0 +1,155 @@
    31.4 +//  Copyright (c) 2006, Giovanni P. Deretta
    31.5 +//
    31.6 +//  This code may be used under either of the following two licences:
    31.7 +//
    31.8 +//  Permission is hereby granted, free of charge, to any person obtaining a copy 
    31.9 +//  of this software and associated documentation files (the "Software"), to deal 
   31.10 +//  in the Software without restriction, including without limitation the rights 
   31.11 +//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 
   31.12 +//  copies of the Software, and to permit persons to whom the Software is 
   31.13 +//  furnished to do so, subject to the following conditions:
   31.14 +//
   31.15 +//  The above copyright notice and this permission notice shall be included in 
   31.16 +//  all copies or substantial portions of the Software.
   31.17 +//
   31.18 +//  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
   31.19 +//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
   31.20 +//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
   31.21 +//  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
   31.22 +//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
   31.23 +//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 
   31.24 +//  THE SOFTWARE. OF SUCH DAMAGE.
   31.25 +//
   31.26 +//  Or:
   31.27 +//
   31.28 +//  Distributed under the Boost Software License, Version 1.0.
   31.29 +//  (See accompanying file LICENSE_1_0.txt or copy at
   31.30 +//  http://www.boost.org/LICENSE_1_0.txt)
   31.31 +
   31.32 +#ifndef BOOST_COROUTINE_GENERATOR_HPP_20060812
   31.33 +#define BOOST_COROUTINE_GENERATOR_HPP_20060812
   31.34 +#include <iterator>
   31.35 +#include <boost/optional.hpp>
   31.36 +#include <boost/none.hpp>
   31.37 +#include <boost/coroutine/shared_coroutine.hpp>
   31.38 +namespace boost { namespace coroutines {
   31.39 +
   31.40 +  namespace detail {
   31.41 +    template<typename T>
   31.42 +    class tag {};
   31.43 +
   31.44 +    class empty {};
   31.45 +
   31.46 +    template<typename Category, typename ValueType>
   31.47 +    struct make_std_iterator {
   31.48 +      typedef std::iterator<Category,
   31.49 +			    ValueType,
   31.50 +			    std::ptrdiff_t,
   31.51 +			    BOOST_DEDUCED_TYPENAME boost::remove_reference<ValueType>::type *, //pointer
   31.52 +			    BOOST_DEDUCED_TYPENAME boost::remove_reference<ValueType>::type & //reference
   31.53 +			    > type;
   31.54 +    };
   31.55 +  }
   31.56 +
   31.57 +  // This simple class implement generators (a simple
   31.58 +  // subset of coroutines) in the form of an InputIterator
   31.59 +  // interface. It also models to the AdaptableGenerator concept.
   31.60 +  // Finally it is ConvertibleToBool.
   31.61 +  template<typename ValueType, 
   31.62 +	   typename Coroutine = 
   31.63 +	   shared_coroutine<ValueType()> >
   31.64 +  class generator : public boost::mpl::eval_if<boost::is_same<ValueType, void>,
   31.65 +					       boost::mpl::identity<detail::empty>,
   31.66 +					       detail::make_std_iterator<
   31.67 +    std::input_iterator_tag, 
   31.68 +    typename Coroutine::result_type> >::type {
   31.69 +    typedef void(generator::*safe_bool)();
   31.70 +    typedef ValueType internal_value_type;
   31.71 +
   31.72 +  public:
   31.73 +    typedef Coroutine coroutine_type;
   31.74 +    typedef BOOST_DEDUCED_TYPENAME 
   31.75 +    coroutine_type::result_type result_type;
   31.76 +    typedef result_type value_type;
   31.77 +
   31.78 +    typedef BOOST_DEDUCED_TYPENAME coroutine_type::self self;
   31.79 +
   31.80 +    generator() {}
   31.81 +
   31.82 +    template<typename Functor>
   31.83 +    generator(Functor f) :
   31.84 +      m_coro(f),
   31.85 +      m_val(assign(detail::tag<result_type>())){};
   31.86 +
   31.87 +    generator(const generator& rhs) :
   31.88 +      m_coro(rhs.m_coro),
   31.89 +      m_val(rhs.m_val) {}
   31.90 +
   31.91 +    value_type operator*() {
   31.92 +      return *m_val;
   31.93 +    }
   31.94 +
   31.95 +    generator& operator++() {
   31.96 +      m_val = assign(detail::tag<result_type>());
   31.97 +      return *this;
   31.98 +    }
   31.99 +
  31.100 +    generator operator++(int) {
  31.101 +      generator t(*this);
  31.102 +      ++(*this);
  31.103 +      return t;
  31.104 +    }
  31.105 +
  31.106 +    friend
  31.107 +    bool operator==(const generator& lhs, const generator& rhs) {
  31.108 +      return lhs.m_val == rhs.m_val;
  31.109 +    }
  31.110 +
  31.111 +    friend 
  31.112 +    bool operator != (const generator& lhs, const generator & rhs) {
  31.113 +      return !(lhs == rhs);
  31.114 +    }
  31.115 +
  31.116 +    operator safe_bool () const {
  31.117 +      return m_val? &generator::safe_bool_true: 0;
  31.118 +    }
  31.119 +
  31.120 +    value_type operator()() {
  31.121 +      return *(*this)++;
  31.122 +    }
  31.123 +
  31.124 +  private:
  31.125 +    void safe_bool_true () {};
  31.126 +
  31.127 +    // hack to handle correctly void result types.
  31.128 +    struct optional_void {
  31.129 +      optional_void() : m_result(true) {}
  31.130 +      optional_void(boost::none_t) : m_result(false) {}
  31.131 +
  31.132 +      void operator*() const {}
  31.133 +      operator bool() const { return m_result; };
  31.134 +      bool m_result;
  31.135 +    };
  31.136 +
  31.137 +    typedef BOOST_DEDUCED_TYPENAME
  31.138 +    boost::mpl::if_<boost::is_same<value_type, void>,
  31.139 +		    optional_void,
  31.140 +		    boost::optional<value_type> >::type optional_type;
  31.141 +
  31.142 +    template<typename T>
  31.143 +    optional_type assign(detail::tag<T>) {
  31.144 +      return m_coro? m_coro(std::nothrow): boost::none;
  31.145 +    }
  31.146 +
  31.147 +    optional_type assign(detail::tag<void>) {
  31.148 +      return m_coro? (m_coro(std::nothrow), optional_type()): boost::none;
  31.149 +    }
  31.150 +
  31.151 +    // There is a possible EBO here. May be use compressed pair.
  31.152 +    coroutine_type m_coro;
  31.153 +    optional_type m_val;
  31.154 +
  31.155 +  };
  31.156 +
  31.157 +} }
  31.158 +#endif
    32.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    32.2 +++ b/boost_1_45_0/boost/coroutine/move.hpp	Fri Mar 04 12:51:59 2011 -0800
    32.3 @@ -0,0 +1,322 @@
    32.4 +//  Copyright (c) 2006, Giovanni P. Deretta
    32.5 +//
    32.6 +//  This code may be used under either of the following two licences:
    32.7 +//
    32.8 +//  Permission is hereby granted, free of charge, to any person obtaining a copy 
    32.9 +//  of this software and associated documentation files (the "Software"), to deal 
   32.10 +//  in the Software without restriction, including without limitation the rights 
   32.11 +//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 
   32.12 +//  copies of the Software, and to permit persons to whom the Software is 
   32.13 +//  furnished to do so, subject to the following conditions:
   32.14 +//
   32.15 +//  The above copyright notice and this permission notice shall be included in 
   32.16 +//  all copies or substantial portions of the Software.
   32.17 +//
   32.18 +//  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
   32.19 +//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
   32.20 +//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
   32.21 +//  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
   32.22 +//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
   32.23 +//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 
   32.24 +//  THE SOFTWARE. OF SUCH DAMAGE.
   32.25 +//
   32.26 +//  Or:
   32.27 +//
   32.28 +//  Distributed under the Boost Software License, Version 1.0.
   32.29 +//  (See accompanying file LICENSE_1_0.txt or copy at
   32.30 +//  http://www.boost.org/LICENSE_1_0.txt)
   32.31 +
   32.32 +
   32.33 +// (C) Copyright David Abrahams 2004-2005.
   32.34 +// Distributed under the Boost
   32.35 +// Software License, Version 1.0. (See accompanying
   32.36 +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
   32.37 +
   32.38 +//
   32.39 +// move.hpp, modified for inclusion in coroutines/detail.
   32.40 +// It support movable only types (i.e. explicit move or move 
   32.41 +// from rvalue).
   32.42 +// 
   32.43 +// This file should be removed (and coroutine updated)
   32.44 +// when/if the original move.hpp is included in boost
   32.45 +//
   32.46 +// Note some move support for older compilers is left inplace even if
   32.47 +// Boost.Coroutine is not really supported on them.
   32.48 +// 
   32.49 +#ifndef BOOST_COROUTINE_MOVE_HPP_20060703
   32.50 +#define BOOST_COROUTINE_MOVE_HPP_20060703
   32.51 +
   32.52 +#include <boost/type_traits/is_convertible.hpp>
   32.53 +#include <boost/mpl/if.hpp>
   32.54 +#include <boost/preprocessor/seq/seq.hpp>
   32.55 +#include <boost/preprocessor/seq/elem.hpp>
   32.56 +#include <boost/preprocessor/identity.hpp>
   32.57 +#include <boost/detail/workaround.hpp>
   32.58 +#include <boost/coroutine/detail/has_swap.hpp>
   32.59 +
   32.60 +#if  BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
   32.61 +#include <boost/ref.hpp>
   32.62 +#include <boost/type_traits/is_class.hpp>
   32.63 +// MSVC 6/7 decides the implicit move assignment operator is ambiguous.
   32.64 +# define BOOST_COROUTINE_MOVE_COPY_SWAP_ASSIGN // Also binds rvalues to non-const refs in assignment
   32.65 +#endif
   32.66 +
   32.67 +// Normal EDG like Comeau does enough (N)RVO that the only case where
   32.68 +// turning on the move construction hacks help is when *explicitly*
   32.69 +// direct-initializing an object.  These cases are important, but the
   32.70 +// hacks break down in strict mode.
   32.71 +
   32.72 +// Borland will always copy a temporary when used in a direct
   32.73 +// initialization.  Enabling the move construction hacks just makes
   32.74 +// the compiler ICE, so we'll skip 'em
   32.75 +
   32.76 +// Intel 8.x on win32 needs help on direct initialization because it
   32.77 +// won't automatically elide copies.  Earlier versions don't seem to
   32.78 +// respond to the move construction hacks, because they blithely bind
   32.79 +// rvalues to non-const references.
   32.80 +
   32.81 +#if defined(BOOST_INTEL_CXX_VERSION) 
   32.82 +# if !defined(_MSC_VER) /* Intel-Linux */ \
   32.83 +  || BOOST_INTEL_CXX_VERSION >= 800
   32.84 +
   32.85 +#  define BOOST_COROUTINE_IMPLICIT_MOVE_CTOR_FOR_COPYABLE_TYPES
   32.86 +
   32.87 +# else
   32.88 +
   32.89 +// because of the way rvalues bind to non-const references, move
   32.90 +// assignment is never called implicitly.  This at least avoids a copy
   32.91 +// when the source is a genuine rvalue.
   32.92 +#  define BOOST_COROUTINE_MOVE_COPY_SWAP_ASSIGN
   32.93 +
   32.94 +# endif 
   32.95 +#endif 
   32.96 +
   32.97 +namespace boost { namespace coroutines { 
   32.98 +
   32.99 +// This is the class that enables the distinction of const lvalues in
  32.100 +// the move overload set in case you don't like using the templated
  32.101 +// reference method.  Movable types T used with const_lvalue overloads
  32.102 +// must have a separate conversion to const_lvalue<T>
  32.103 +template <class X>
  32.104 +struct const_lvalue
  32.105 +{
  32.106 +    explicit const_lvalue(X const* p)
  32.107 +      : p(p) {}
  32.108 +
  32.109 +    // It acts like a smart pointer, for syntactic convenience
  32.110 +    X const& operator*() const { return *p; }
  32.111 +    
  32.112 +    X const* operator->() const { return p; }
  32.113 +
  32.114 +#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
  32.115 +    // A convenience for constructors taking a const_lvalue.  As a
  32.116 +    // result, implicit_cast<X const&>(rhs) can be used to get at the
  32.117 +    // rhs uniformly.
  32.118 +    operator X const&() const { return **this; }
  32.119 +#endif 
  32.120 +    
  32.121 +    friend inline X const& copy_source(const_lvalue<X> x) { return *x; }
  32.122 +#ifdef BOOST_COROUTINE_DEBUG_MOVE
  32.123 +    ~const_lvalue()
  32.124 +    {
  32.125 +        p =0;
  32.126 +    }
  32.127 +#endif
  32.128 +    
  32.129 + protected:
  32.130 +    X const* p; // this pointer will refer to the object from which to move
  32.131 +};
  32.132 +
  32.133 +template <class T>
  32.134 +inline T const& copy_source(T& x) { return x; }
  32.135 +    
  32.136 +template <class X>
  32.137 +struct move_from : const_lvalue<X>
  32.138 +{
  32.139 +    explicit move_from(X* p)
  32.140 +      : const_lvalue<X>(p) {}
  32.141 +
  32.142 +    // Some compilers need this; seems to do no harm in general.
  32.143 +    explicit move_from(X& x)
  32.144 +      : const_lvalue<X>(&x) {}
  32.145 +
  32.146 +#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
  32.147 +    // It would be perverse if we inherited const_lvalue's conversion
  32.148 +    // to X const& without providing this one.
  32.149 +    operator X&() const { return **this; }
  32.150 +#endif 
  32.151 +    
  32.152 +    // It acts like a smart pointer, for syntactic convenience
  32.153 +    X& operator*() const { return *const_cast<X*>(this->p); }
  32.154 +    X* operator->() const { return const_cast<X*>(this->p); }
  32.155 +};
  32.156 +
  32.157 +// Detect whether T is movable
  32.158 +template <class T>
  32.159 +struct is_movable
  32.160 +  : boost::is_convertible<T,move_from<T> >
  32.161 +{
  32.162 +};
  32.163 +
  32.164 +#if defined(BOOST_COROUTINE_MOVE_COPY_SWAP_ASSIGN) || defined(__BORLANDC__)
  32.165 +namespace move_
  32.166 +{
  32.167 +# if BOOST_WORKAROUND(BOOST_MSVC, == 1300)
  32.168 +  
  32.169 +  template <class T>
  32.170 +  struct move_result
  32.171 +    : mpl::if_<
  32.172 +          is_class<T>,
  32.173 +          typename mpl::if_<
  32.174 +              is_movable<T>
  32.175 +            , move_from<T>
  32.176 +            , reference_wrapper<T>
  32.177 +          >::type
  32.178 +        , T&
  32.179 +      >
  32.180 +  {};
  32.181 +  
  32.182 +# else // default version
  32.183 +  
  32.184 +  template <class T>
  32.185 +  struct move_result
  32.186 +    : mpl::if_< is_movable<T>, move_from<T> , T& >
  32.187 +  {};
  32.188 +
  32.189 +# endif 
  32.190 +}
  32.191 +
  32.192 +template <class T>
  32.193 +typename move_::move_result<T>::type
  32.194 +move(T& x)
  32.195 +{
  32.196 +    typedef typename move_::move_result<T>::type r;
  32.197 +    return r(x);
  32.198 +}
  32.199 +
  32.200 +#else 
  32.201 +
  32.202 +template <class T>
  32.203 +inline
  32.204 +typename boost::mpl::if_<
  32.205 +    is_movable<T>
  32.206 +  , T
  32.207 +  , T&
  32.208 +>::type
  32.209 +move(T& x)
  32.210 +{
  32.211 +    typedef typename boost::mpl::if_<
  32.212 +        is_movable<T>
  32.213 +      , move_from<T>
  32.214 +      , T&
  32.215 +    >::type r1;
  32.216 +
  32.217 +    typedef typename boost::mpl::if_<
  32.218 +    is_movable<T>
  32.219 +        , T
  32.220 +        , T&
  32.221 +    >::type r2;
  32.222 +   
  32.223 +    return r2(r1(x));
  32.224 +}
  32.225 +
  32.226 +#endif 
  32.227 +
  32.228 +// CRTP base class for conveniently making movable types.  You don't
  32.229 +// have to use this to make a type movable (if, for example, you don't
  32.230 +// want the MI non-EBO penalty); you just need to provide the
  32.231 +// conversion to move_from<Derived> yourself in that case.
  32.232 +template <class Derived>
  32.233 +struct movable
  32.234 +{
  32.235 +    operator move_from<Derived>()
  32.236 +    {
  32.237 +        return move_from<Derived>(static_cast<Derived*>(this));
  32.238 +    }
  32.239 +
  32.240 +    operator const_lvalue<Derived>() const
  32.241 +    {
  32.242 +        return const_lvalue<Derived>(static_cast<Derived const*>(this));
  32.243 +    }
  32.244 +    
  32.245 + protected:
  32.246 +    movable() {}
  32.247 +    
  32.248 + private:
  32.249 +    // any class that wants to be movable should to define its copy
  32.250 +    // ctor and assignment using the macros below, or else those
  32.251 +    // should remain private.
  32.252 +    movable(movable&);
  32.253 +    movable& operator=(movable&);
  32.254 +};
  32.255 +
  32.256 +namespace move_
  32.257 +{
  32.258 +  // Algorithms lifted directly from
  32.259 +  // http://std.dkuug.dk/jtc1/sc22/wg21/docs/papers/2002/n1377.htm
  32.260 +  template <class T>
  32.261 +  void
  32.262 +  swap(T& a, T& b)
  32.263 +  {
  32.264 +      T tmp(boost::coroutines::move(a));
  32.265 +      a = boost::coroutines::move(b);
  32.266 +      b = boost::coroutines::move(tmp);
  32.267 +  }
  32.268 +}
  32.269 +
  32.270 +using move_::swap;
  32.271 +
  32.272 +// This is for GCC2 compatibility.  GCC2's standard lib puts std::swap
  32.273 +// into the global namespace, causing ambiguities with boost::swap
  32.274 +// when brought in with a using declaration.
  32.275 +namespace move_swap_
  32.276 +{
  32.277 +  template <class T>
  32.278 +  void
  32.279 +  move_swap(T& a, T& b, mpl::true_)
  32.280 +  {
  32.281 +      swap(a,b); // use ADL
  32.282 +  }
  32.283 +
  32.284 +  template <class T>
  32.285 +  void
  32.286 +  move_swap(T& a, T& b, mpl::false_)
  32.287 +  {
  32.288 +      move_::swap(a,b);
  32.289 +  }
  32.290 +  
  32.291 +  template <class T>
  32.292 +  void
  32.293 +  move_swap(T& a, T& b)
  32.294 +  {
  32.295 +      typedef typename has_swap<T>::type has_swap_;
  32.296 +      move_swap(a,b, has_swap_());
  32.297 +  }
  32.298 +}
  32.299 +
  32.300 +using move_swap_::move_swap;
  32.301 +
  32.302 +// I wonder whether it's a good idea to have the 1-argument and
  32.303 +// 3-argument overloads that do different things?
  32.304 +template <class InputIterator, class OutputIterator>
  32.305 +OutputIterator
  32.306 +move(InputIterator first, InputIterator last, OutputIterator result)
  32.307 +{
  32.308 +    for (; first != last; ++first, ++result)
  32.309 +        *result = move(*first, 0);
  32.310 +    return result;
  32.311 +}
  32.312 + 
  32.313 +template <class BidirectionalIterator1, class BidirectionalIterator2>
  32.314 +BidirectionalIterator2
  32.315 +move_backward(BidirectionalIterator1 first, BidirectionalIterator1 last,
  32.316 +              BidirectionalIterator2 result)
  32.317 +{
  32.318 +    while (last != first)
  32.319 +        *--result = move(*--last, 0);
  32.320 +    return result;
  32.321 +}
  32.322 +
  32.323 +} } 
  32.324 +
  32.325 +#endif 
    33.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    33.2 +++ b/boost_1_45_0/boost/coroutine/shared_coroutine.hpp	Fri Mar 04 12:51:59 2011 -0800
    33.3 @@ -0,0 +1,72 @@
    33.4 +//  Copyright (c) 2006, Giovanni P. Deretta
    33.5 +//
    33.6 +//  This code may be used under either of the following two licences:
    33.7 +//
    33.8 +//  Permission is hereby granted, free of charge, to any person obtaining a copy 
    33.9 +//  of this software and associated documentation files (the "Software"), to deal 
   33.10 +//  in the Software without restriction, including without limitation the rights 
   33.11 +//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 
   33.12 +//  copies of the Software, and to permit persons to whom the Software is 
   33.13 +//  furnished to do so, subject to the following conditions:
   33.14 +//
   33.15 +//  The above copyright notice and this permission notice shall be included in 
   33.16 +//  all copies or substantial portions of the Software.
   33.17 +//
   33.18 +//  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
   33.19 +//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
   33.20 +//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
   33.21 +//  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
   33.22 +//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
   33.23 +//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 
   33.24 +//  THE SOFTWARE. OF SUCH DAMAGE.
   33.25 +//
   33.26 +//  Or:
   33.27 +//
   33.28 +//  Distributed under the Boost Software License, Version 1.0.
   33.29 +//  (See accompanying file LICENSE_1_0.txt or copy at
   33.30 +//  http://www.boost.org/LICENSE_1_0.txt)
   33.31 +
   33.32 +#ifndef BOOST_COROUTINE_SHARED_COROUTINE_HPP_20060812
   33.33 +#define BOOST_COROUTINE_SHARED_COROUTINE_HPP_20060812
   33.34 +#include <boost/coroutine/coroutine.hpp>
   33.35 +namespace boost { namespace coroutines {
   33.36 +  // This class is a workaround for the widespread lack of move
   33.37 +  // semantics support. It is a refrence counted wrapper around 
   33.38 +  // the coroutine object.
   33.39 +  // FIXME: ATM a shared_coroutine is-a coroutine. This is to avoid
   33.40 +  // inheriting privately and cluttering the code with lots of using
   33.41 +  // declarations to unhide coroutine members and nested types.
   33.42 +  // From a purity point of view, coroutines and shared_coroutines should
   33.43 +  // be two different types.
   33.44 +  template<typename Signature, typename ContextImpl = detail::default_context_impl> 
   33.45 +  class shared_coroutine : public coroutine<Signature, ContextImpl> {
   33.46 +  public:
   33.47 +    typedef coroutine<Signature, ContextImpl> coroutine_type;
   33.48 +
   33.49 +    shared_coroutine() {}
   33.50 +
   33.51 +    template<typename Functor>
   33.52 +    shared_coroutine(Functor f, 
   33.53 +		     std::ptrdiff_t stack_size = 
   33.54 +		     detail::default_stack_size) :
   33.55 +      coroutine_type(f, stack_size) {}
   33.56 +
   33.57 +    shared_coroutine(move_from<coroutine_type> src):
   33.58 +      coroutine_type(src) {}
   33.59 +
   33.60 +    shared_coroutine(const shared_coroutine& rhs) :
   33.61 +      coroutine_type(rhs.m_pimpl.get(), detail::init_from_impl_tag()) {}
   33.62 +
   33.63 +    shared_coroutine& operator=(move_from<coroutine_type> src) {
   33.64 +      shared_coroutine(src).swap(*this);
   33.65 +      return *this;
   33.66 +    }
   33.67 +
   33.68 +    shared_coroutine& operator=(const shared_coroutine& rhs) {
   33.69 +      shared_coroutine(rhs).swap(*this);
   33.70 +      return *this;
   33.71 +    }    
   33.72 +  private:
   33.73 +  };
   33.74 +} }
   33.75 +#endif
    34.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    34.2 +++ b/boost_1_45_0/boost/coroutine/tuple_traits.hpp	Fri Mar 04 12:51:59 2011 -0800
    34.3 @@ -0,0 +1,170 @@
    34.4 +//  Copyright (c) 2006, Giovanni P. Deretta
    34.5 +//
    34.6 +//  This code may be used under either of the following two licences:
    34.7 +//
    34.8 +//  Permission is hereby granted, free of charge, to any person obtaining a copy 
    34.9 +//  of this software and associated documentation files (the "Software"), to deal 
   34.10 +//  in the Software without restriction, including without limitation the rights 
   34.11 +//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 
   34.12 +//  copies of the Software, and to permit persons to whom the Software is 
   34.13 +//  furnished to do so, subject to the following conditions:
   34.14 +//
   34.15 +//  The above copyright notice and this permission notice shall be included in 
   34.16 +//  all copies or substantial portions of the Software.
   34.17 +//
   34.18 +//  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
   34.19 +//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
   34.20 +//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
   34.21 +//  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
   34.22 +//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
   34.23 +//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 
   34.24 +//  THE SOFTWARE. OF SUCH DAMAGE.
   34.25 +//
   34.26 +//  Or:
   34.27 +//
   34.28 +//  Distributed under the Boost Software License, Version 1.0.
   34.29 +//  (See accompanying file LICENSE_1_0.txt or copy at
   34.30 +//  http://www.boost.org/LICENSE_1_0.txt)
   34.31 +
   34.32 +#ifndef BOOST_COROUTINE_TUPLE_TRAITS_HPP_20060613
   34.33 +#define BOOST_COROUTINE_TUPLE_TRAITS_HPP_20060613
   34.34 +#include <boost/tuple/tuple.hpp>
   34.35 +#include <boost/preprocessor/repetition/enum_binary_params.hpp>
   34.36 +#include <boost/preprocessor/facilities/intercept.hpp>
   34.37 +#include <boost/type_traits.hpp>
   34.38 +#include <boost/mpl/eval_if.hpp>
   34.39 +#include <boost/mpl/if.hpp>
   34.40 +#include <boost/mpl/identity.hpp>
   34.41 +#include <boost/mpl/bool.hpp>
   34.42 +#include <boost/coroutine/detail/arg_max.hpp>
   34.43 +
   34.44 +namespace boost { namespace coroutines {
   34.45 +  namespace detail {
   34.46 +    /*
   34.47 +     * NOTE & FIXME: coroutine_traits relies on the fact that we can construct a
   34.48 +     * boost::tuple specifing more arguments of type null_type than
   34.49 +     * required without generating an error. This is an undocumented
   34.50 +     * 'feature' and doesn't actually  work for nullary tuples,
   34.51 +     * so we need to detect this case and handle it with tuple_workaround.
   34.52 +     * If ever boost::tuple is changed (for example by switching to fusion)
   34.53 +     * tuple_workaround should be used in all cases to handle extra 
   34.54 +     * parameters.
   34.55 +     * The real solution would be to have an internal tuple
   34.56 +     * type that derives from boost::tuple and handles all cases we care about.
   34.57 +     * Or better, just use Boost.Fusion.
   34.58 +     * In general the code in this file needs to be put in a better shape,
   34.59 +     * eliminating all corner cases.
   34.60 +     */
   34.61 +
   34.62 +    /* 
   34.63 +     * A boost::tuple<> is not constructible from an arbitrary
   34.64 +     * number of null_types (while non nullary tuples are).
   34.65 +     * This class takes care of this assimmetry.
   34.66 +     */
   34.67 +    struct tuple_workaround : boost::tuple<> {
   34.68 +#     define BOOST_COROUTINE_arg_null_typecr(z, n, unused)\
   34.69 +	const boost::tuples::null_type&                   \
   34.70 +      /**/
   34.71 +	
   34.72 +      tuple_workaround
   34.73 +      (BOOST_PP_ENUM
   34.74 +       (BOOST_COROUTINE_ARG_MAX, 
   34.75 +	BOOST_COROUTINE_arg_null_typecr,
   34.76 +	~)){}
   34.77 +	
   34.78 +      tuple_workaround(const tuple_workaround&) {}
   34.79 +      tuple_workaround() {}
   34.80 +#     undef BOOST_COROUTINE_arg_null_typecr
   34.81 +    };
   34.82 +  } /* detail */
   34.83 +
   34.84 +  // All tuple traits must be derived from this
   34.85 +  // class to be correctly recognized.
   34.86 +  struct tuple_traits_tag {};
   34.87 +      
   34.88 +  template<typename T>
   34.89 +  struct get_length {
   34.90 +   enum { length = T::length };
   34.91 +  };
   34.92 +
   34.93 +  template<typename T>
   34.94 +  struct is_nullary :  boost::mpl::bool_<boost::tuples::length<T>::value == 0> {  };
   34.95 +
   34.96 +  template<typename T>
   34.97 +  struct is_singular : boost::mpl::bool_<boost::tuples::length<T>::value == 1> {  };
   34.98 +
   34.99 +  // Given a tuple_traits, makes a tuple of it
  34.100 +  // Simply returns the internal tuple type, unless
  34.101 +  // the tuple is nullary, then apply the nullary tuple workaround
  34.102 +  template<typename T>
  34.103 +  struct make_as_tuple :
  34.104 +    boost::mpl::if_<
  34.105 +    is_nullary<T>,
  34.106 +      detail::tuple_workaround,
  34.107 +      T
  34.108 +    > {};
  34.109 +
  34.110 +  // Used to implement the next metafunction,
  34.111 +  // Splitted in two parts to satisfy the compiler.
  34.112 +  template<typename T>
  34.113 +  struct step_2 :
  34.114 +      boost::mpl::eval_if<
  34.115 +      is_singular<T>,
  34.116 +      boost::tuples::element<0, typename make_as_tuple<T>::type >,
  34.117 +    boost::mpl::identity<typename make_as_tuple<T>::type> > { };
  34.118 +
  34.119 +  // Given a trait class return the internal tuple type modified 
  34.120 +  // as a return value.
  34.121 +  // The algorithm is as follow:
  34.122 +  // - If the tuple is nullary returns 'void'. 
  34.123 +  // - If it singular returns the first type
  34.124 +  // - Else return the tuple itself.
  34.125 +  template<typename T>
  34.126 +  struct make_result_type :
  34.127 +    boost::mpl::eval_if<
  34.128 +    is_nullary<T>,
  34.129 +    boost::mpl::identity<void>,
  34.130 +    step_2<T> > { };
  34.131 +
  34.132 +  template<
  34.133 +    BOOST_PP_ENUM_BINARY_PARAMS
  34.134 +  (BOOST_COROUTINE_ARG_MAX,
  34.135 +   typename T, 
  34.136 +   = boost::tuples::null_type BOOST_PP_INTERCEPT)>
  34.137 +  struct tuple_traits : tuple_traits_tag {
  34.138 +  public:	
  34.139 +
  34.140 +    // This is the straightforward boost::tuple trait
  34.141 +    // derived from the argument list. It is not 
  34.142 +    // directly used in all cases.
  34.143 +    typedef boost::tuple
  34.144 +    <BOOST_PP_ENUM_PARAMS
  34.145 +    (BOOST_COROUTINE_ARG_MAX, T)> internal_tuple_type;
  34.146 +
  34.147 +    // FIXME: Currently coroutine code does not use this typedef in all cases
  34.148 +    // and expect it to be equal to boost::tuples::null_type
  34.149 +    typedef boost::tuples::null_type null_type;
  34.150 +    enum {length = boost::tuples::length<internal_tuple_type>::value};
  34.151 +
  34.152 +    // Return the element at the Indext'th position in the typelist.
  34.153 +    // If the index is not less than the tuple length, it returns 
  34.154 +    // null_type.
  34.155 +    template<int Index> 
  34.156 +    struct at : 
  34.157 +      boost::mpl::eval_if_c<
  34.158 +      Index < 
  34.159 +      boost::tuples::length<typename tuple_traits::internal_tuple_type>::value,
  34.160 +      boost::tuples::element<Index, typename tuple_traits::internal_tuple_type>,	
  34.161 +      boost::mpl::identity<typename tuple_traits::null_type> >{};
  34.162 +
  34.163 +    typedef typename make_as_tuple<internal_tuple_type>::type
  34.164 +    as_tuple;	
  34.165 +
  34.166 +    typedef typename make_result_type<internal_tuple_type>::type as_result;
  34.167 +
  34.168 +  };
  34.169 +    
  34.170 +  template<typename T>
  34.171 +  struct is_tuple_traits : boost::is_base_of<tuple_traits_tag, T> {};
  34.172 +} }
  34.173 +#endif
    35.1 --- a/boost_1_45_0/boost/function/function_template.hpp	Fri Mar 04 12:48:37 2011 -0800
    35.2 +++ b/boost_1_45_0/boost/function/function_template.hpp	Fri Mar 04 12:51:59 2011 -0800
    35.3 @@ -536,7 +536,7 @@
    35.4            // objects, so we invoke through mem_fn() but we retain the
    35.5            // right target_type() values.
    35.6            if (f) {
    35.7 -            this->assign_to(mem_fn(f), functor);
    35.8 +            this->assign_to(boost::mem_fn(f), functor);
    35.9              return true;
   35.10            } else {
   35.11              return false;
   35.12 @@ -549,7 +549,7 @@
   35.13            // objects, so we invoke through mem_fn() but we retain the
   35.14            // right target_type() values.
   35.15            if (f) {
   35.16 -            this->assign_to_a(mem_fn(f), functor, a);
   35.17 +            this->assign_to_a(boost::mem_fn(f), functor, a);
   35.18              return true;
   35.19            } else {
   35.20              return false;

mercurial