push_control_block_cc.hpp 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. // Copyright Oliver Kowalke 2014.
  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_COROUTINES2_DETAIL_PUSH_CONTROL_BLOCK_HPP
  6. #define BOOST_COROUTINES2_DETAIL_PUSH_CONTROL_BLOCK_HPP
  7. #include <exception>
  8. #include <boost/config.hpp>
  9. #include <boost/context/fiber.hpp>
  10. #include <boost/coroutine2/detail/state.hpp>
  11. #ifdef BOOST_HAS_ABI_HEADERS
  12. # include BOOST_ABI_PREFIX
  13. #endif
  14. namespace boost {
  15. namespace coroutines2 {
  16. namespace detail {
  17. template< typename T >
  18. struct push_coroutine< T >::control_block {
  19. boost::context::fiber c;
  20. typename pull_coroutine< T >::control_block * other;
  21. state_t state;
  22. std::exception_ptr except;
  23. static void destroy( control_block * cb) noexcept;
  24. template< typename StackAllocator, typename Fn >
  25. control_block( context::preallocated, StackAllocator &&, Fn &&);
  26. control_block( typename pull_coroutine< T >::control_block *, boost::context::fiber &) noexcept;
  27. control_block( control_block &) = delete;
  28. control_block & operator=( control_block &) = delete;
  29. void deallocate() noexcept;
  30. void resume( T const&);
  31. void resume( T &&);
  32. bool valid() const noexcept;
  33. };
  34. template< typename T >
  35. struct push_coroutine< T & >::control_block {
  36. boost::context::fiber c;
  37. typename pull_coroutine< T & >::control_block * other;
  38. state_t state;
  39. std::exception_ptr except;
  40. static void destroy( control_block * cb) noexcept;
  41. template< typename StackAllocator, typename Fn >
  42. control_block( context::preallocated, StackAllocator &&, Fn &&);
  43. control_block( typename pull_coroutine< T & >::control_block *, boost::context::fiber &) noexcept;
  44. control_block( control_block &) = delete;
  45. control_block & operator=( control_block &) = delete;
  46. void deallocate() noexcept;
  47. void resume( T &);
  48. bool valid() const noexcept;
  49. };
  50. struct push_coroutine< void >::control_block {
  51. boost::context::fiber c;
  52. pull_coroutine< void >::control_block * other;
  53. state_t state;
  54. std::exception_ptr except;
  55. static void destroy( control_block * cb) noexcept;
  56. template< typename StackAllocator, typename Fn >
  57. control_block( context::preallocated, StackAllocator &&, Fn &&);
  58. control_block( pull_coroutine< void >::control_block *, boost::context::fiber &) noexcept;
  59. control_block( control_block &) = delete;
  60. control_block & operator=( control_block &) = delete;
  61. void deallocate() noexcept;
  62. void resume();
  63. bool valid() const noexcept;
  64. };
  65. }}}
  66. #ifdef BOOST_HAS_ABI_HEADERS
  67. # include BOOST_ABI_SUFFIX
  68. #endif
  69. #endif // BOOST_COROUTINES2_DETAIL_PUSH_CONTROL_BLOCK_HPP