Created
February 19, 2017 17:04
-
-
Save heejune/609136dcd0f8e238f7a4872ccfb01fea to your computer and use it in GitHub Desktop.
future_async_methods
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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