state.hpp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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_ASYMMETRIC_COROUTINE_HPP
  6. #define BOOST_COROUTINES2_DETAIL_ASYMMETRIC_COROUTINE_HPP
  7. #include <exception>
  8. #include <boost/assert.hpp>
  9. #include <boost/config.hpp>
  10. #include <boost/coroutine2/detail/config.hpp>
  11. #ifdef BOOST_HAS_ABI_HEADERS
  12. # include BOOST_ABI_PREFIX
  13. #endif
  14. namespace boost {
  15. namespace coroutines2 {
  16. namespace detail {
  17. enum class state_t : unsigned int {
  18. none = 0,
  19. complete = 1 << 1,
  20. unwind = 1 << 2,
  21. destroy = 1 << 3
  22. };
  23. inline
  24. constexpr state_t
  25. operator&( state_t l, state_t r) {
  26. return static_cast< state_t >(
  27. static_cast< unsigned int >( l) & static_cast< unsigned int >( r) );
  28. }
  29. inline
  30. constexpr state_t
  31. operator|( state_t l, state_t r) {
  32. return static_cast< state_t >(
  33. static_cast< unsigned int >( l) | static_cast< unsigned int >( r) );
  34. }
  35. inline
  36. constexpr state_t
  37. operator^( state_t l, state_t r) {
  38. return static_cast< state_t >(
  39. static_cast< unsigned int >( l) ^ static_cast< unsigned int >( r) );
  40. }
  41. inline
  42. constexpr state_t
  43. operator~( state_t l) {
  44. return static_cast< state_t >( ~static_cast< unsigned int >( l) );
  45. }
  46. inline
  47. state_t &
  48. operator&=( state_t & l, state_t r) {
  49. l = l & r;
  50. return l;
  51. }
  52. inline
  53. state_t &
  54. operator|=( state_t & l, state_t r) {
  55. l = l | r;
  56. return l;
  57. }
  58. inline
  59. state_t &
  60. operator^=( state_t & l, state_t r) {
  61. l = l ^ r;
  62. return l;
  63. }
  64. }}}
  65. #ifdef BOOST_HAS_ABI_HEADERS
  66. # include BOOST_ABI_SUFFIX
  67. #endif
  68. #endif // BOOST_COROUTINES2_DETAIL_ASYMMETRIC_COROUTINE_HPP