Skip to content

Commit

Permalink
Adapting to latest changes of TS
Browse files Browse the repository at this point in the history
- replace std::experimental::suspend_if with own implementation
  • Loading branch information
hkaiser committed May 16, 2017
1 parent 2f87fee commit 10e32c4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 26 deletions.
19 changes: 16 additions & 3 deletions hpx/lcos/detail/future_await_traits.hpp
Expand Up @@ -28,6 +28,20 @@
///////////////////////////////////////////////////////////////////////////////
namespace hpx { namespace lcos { namespace detail
{
///////////////////////////////////////////////////////////////////////////
// this was removed from the TS, so we define our own
struct suspend_if
{
bool is_ready_;

explicit suspend_if(bool cond) HPX_NOEXCEPT : is_ready_(!cond) {}

bool await_ready() HPX_NOEXCEPT { return is_ready_; }
void await_suspend(std::experimental::coroutine_handle<>) HPX_NOEXCEPT {}
void await_resume() HPX_NOEXCEPT {}
};

///////////////////////////////////////////////////////////////////////////
// Allow using co_await with an expression which evaluates to
// hpx::future<T>.
template <typename T>
Expand Down Expand Up @@ -125,13 +139,12 @@ namespace hpx { namespace lcos { namespace detail
return std::experimental::suspend_never{};
}

std::experimental::suspend_if final_suspend()
suspend_if final_suspend()
{
// This gives up the coroutine's reference count on the shared
// state. If this was the last reference count, the coroutine
// should not suspend before exiting.
return std::experimental::suspend_if{
!this->base_type::requires_delete()};
return suspend_if{!this->base_type::requires_delete()};
}

void set_exception(std::exception_ptr e)
Expand Down
23 changes: 0 additions & 23 deletions hpx/util/await_traits.hpp
Expand Up @@ -142,29 +142,6 @@ namespace std { namespace experimental
{
}
};

struct suspend_if
{
private:
bool b_;

public:
suspend_if(bool b)
: b_(b)
{
}

bool await_ready() const
{
return !b_;
}
void await_suspend(coroutine_handle<>) const
{
}
void await_resume() const
{
}
};
}}

#endif // defined(HPX_HAVE_EMULATE_COROUTINE_SUPPORT_LIBRARY)
Expand Down

0 comments on commit 10e32c4

Please sign in to comment.