Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:30:31

0001 
0002 //          Copyright Oliver Kowalke 2009.
0003 // Distributed under the Boost Software License, Version 1.0.
0004 //    (See accompanying file LICENSE_1_0.txt or copy at
0005 //          http://www.boost.org/LICENSE_1_0.txt)
0006 
0007 #ifndef BOOST_COROUTINES_DETAIL_COROUTINE_CONTEXT_H
0008 #define BOOST_COROUTINES_DETAIL_COROUTINE_CONTEXT_H
0009 
0010 #include <cstddef>
0011 
0012 #include <boost/assert.hpp>
0013 #include <boost/config.hpp>
0014 #include <boost/context/detail/fcontext.hpp>
0015 
0016 #include <boost/coroutine/detail/config.hpp>
0017 #include <boost/coroutine/detail/preallocated.hpp>
0018 #include <boost/coroutine/stack_context.hpp>
0019 
0020 #ifdef BOOST_HAS_ABI_HEADERS
0021 #  include BOOST_ABI_PREFIX
0022 #endif
0023 
0024 namespace boost {
0025 namespace coroutines {
0026 namespace detail {
0027 
0028 // class hold stack-context and coroutines execution-context
0029 class BOOST_COROUTINES_DECL coroutine_context
0030 {
0031 private:
0032     template< typename Coro >
0033     friend void trampoline( context::detail::transfer_t);
0034     template< typename Coro >
0035     friend void trampoline_void( context::detail::transfer_t);
0036     template< typename Coro >
0037     friend void trampoline_pull( context::detail::transfer_t);
0038     template< typename Coro >
0039     friend void trampoline_push( context::detail::transfer_t);
0040     template< typename Coro >
0041     friend void trampoline_push_void( context::detail::transfer_t);
0042 
0043     preallocated            palloc_;
0044     context::detail::fcontext_t     ctx_;
0045 
0046 public:
0047     typedef void( * ctx_fn)( context::detail::transfer_t);
0048 
0049     // default ctor represents the current execution-context
0050     coroutine_context();
0051 
0052     // ctor creates a new execution-context running coroutine-fn `fn`
0053     // `ctx_` will be allocated on top of the stack managed by parameter
0054     // `stack_ctx`
0055     coroutine_context( ctx_fn fn, preallocated const& palloc);
0056 
0057     coroutine_context( coroutine_context const&);
0058 
0059     coroutine_context& operator=( coroutine_context const&);
0060 
0061     void * jump( coroutine_context &, void * = 0);
0062 
0063     stack_context & stack_ctx()
0064     { return palloc_.sctx; }
0065 };
0066 
0067 }}}
0068 
0069 #ifdef BOOST_HAS_ABI_HEADERS
0070 #  include BOOST_ABI_SUFFIX
0071 #endif
0072 
0073 #endif // BOOST_COROUTINES_DETAIL_COROUTINE_CONTEXT_H