Skip to content

Instantly share code, notes, and snippets.

@heejune
Created February 19, 2017 17:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save heejune/609136dcd0f8e238f7a4872ccfb01fea to your computer and use it in GitHub Desktop.
Save heejune/609136dcd0f8e238f7a4872ccfb01fea to your computer and use it in GitHub Desktop.
future_async_methods
template<class _Ty>
bool await_ready(future<_Ty>& _Fut)
{
return (_Fut._Is_ready());
}
template<class _Ty>
void await_suspend(future<_Ty>& _Fut,
experimental::coroutine_handle<> _ResumeCb)
{ // change to .then when future gets .then
thread _WaitingThread([&_Fut, _ResumeCb]{
_Fut.wait();
_ResumeCb();
});
_WaitingThread.detach();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment