trampoline_push.hpp 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. // Copyright Oliver Kowalke 2009.
  2. // Distributed under the Boost Software License, Version 1.0.
  3. // (See accompanying file LICENSE_1_0.txt or copy at
  4. // http://www.boost.org/LICENSE_1_0.txt)
  5. #ifndef BOOST_COROUTINES_DETAIL_TRAMPOLINE_PUSH_H
  6. #define BOOST_COROUTINES_DETAIL_TRAMPOLINE_PUSH_H
  7. #include <cstddef>
  8. #include <boost/assert.hpp>
  9. #include <boost/config.hpp>
  10. #include <boost/context/detail/fcontext.hpp>
  11. #include <boost/cstdint.hpp>
  12. #include <boost/exception_ptr.hpp>
  13. #include <boost/move/move.hpp>
  14. #include <boost/coroutine/detail/config.hpp>
  15. #include <boost/coroutine/detail/data.hpp>
  16. #include <boost/coroutine/detail/flags.hpp>
  17. #include <boost/coroutine/detail/parameters.hpp>
  18. #include <boost/coroutine/detail/setup.hpp>
  19. #include <boost/coroutine/detail/setup.hpp>
  20. #include <boost/coroutine/exceptions.hpp>
  21. #include <boost/coroutine/flags.hpp>
  22. #ifdef BOOST_HAS_ABI_HEADERS
  23. # include BOOST_ABI_PREFIX
  24. #endif
  25. namespace boost {
  26. namespace coroutines {
  27. namespace detail {
  28. template< typename Coro >
  29. void trampoline_push( context::detail::transfer_t t)
  30. {
  31. typedef typename Coro::param_type param_type;
  32. data_t * data = static_cast< data_t * >( t.data);
  33. data->from->ctx_ = t.fctx;
  34. param_type * param(
  35. static_cast< param_type * >( data->data) );
  36. BOOST_ASSERT( 0 != param);
  37. BOOST_ASSERT( 0 != param->data);
  38. Coro * coro(
  39. static_cast< Coro * >( param->coro) );
  40. BOOST_ASSERT( 0 != coro);
  41. coro->run( param->data);
  42. }
  43. template< typename Coro >
  44. void trampoline_push_void( context::detail::transfer_t t)
  45. {
  46. typedef typename Coro::param_type param_type;
  47. data_t * data = static_cast< data_t * >( t.data);
  48. data->from->ctx_ = t.fctx;
  49. param_type * param(
  50. static_cast< param_type * >( data->data) );
  51. BOOST_ASSERT( 0 != param);
  52. Coro * coro(
  53. static_cast< Coro * >( param->coro) );
  54. BOOST_ASSERT( 0 != coro);
  55. coro->run();
  56. }
  57. }}}
  58. #ifdef BOOST_HAS_ABI_HEADERS
  59. # include BOOST_ABI_SUFFIX
  60. #endif
  61. #endif // BOOST_COROUTINES_DETAIL_TRAMPOLINE_PUSH_H