/*T ->return type, E -> error type, D -> parameter type */
template<typename T, typename E, typename D = void>
using result_t = typename internal::result_t<T, E, D>::type;
第一个参数类型T是返回的Result<1, 2>中参数1,第二个参数类型参数E为参数2,参数D为函数参数的类型.
template<typename T>
struct State
{
    std::mutex                            mutex;
    std::experimental::optional<T>        value;
    std::unique_ptr<detail::ContinuationBase<T&>> continuation;   // 注意这里并不是一个引用类型, 而是一个 ContinuationBase<int&> class类似, ContinuationBase是不用做引用类型的初始化.
}
template<typename T>
class Promise
{
.....
private:
    std::shared_ptr<typename detail::State<T>> _state;
};
template<typename T>
class Future
{
private:
    std::shared_ptr<detail::State<T>> _state;
    friend class Promise<T>;
};
Promise 和 Future 通过 std::shared_ptr<detail::State<T>> _state;连接.
template<typename... Args>
class ContinuationBase
{
public:
    virtual ~ContinuationBase() {}
    virtual void operator () (Args&&... args) = 0;
};
template<typename F, typename... Args>
class Continuation : public ContinuationBase<Args...>
{
    static_assert(!std::is_reference<F> {}, "F cannot be a reference");
public:
    typedef result_of<F, Args...> result_type;
    Continuation(const F& fun) : _fun(fun)
    {
    }
    Continuation(F&& fun) : _fun(std::move(fun))
    {
    }
}

最新文章

  1. 【bzoj3211】花神游历各国
  2. Unity 热更新实例一、C#Light 和UI系统使用实例
  3. 如何解决Android SDK中离线文档打开慢的问题
  4. Windows-005-显示隐藏文件
  5. 网络攻击之二:XSS(之一是SQL注入,前面有文章)
  6. mybatis 打印 sql
  7. 加密算法 - RSA算法二
  8. Linux 系统下查看硬件信息命令大全
  9. 再淡spring jdbc 连接池断开重连设置
  10. muduo网络图书馆评测
  11. php实现分页
  12. 用u盘装系统,进入bios后没有usb启动项怎么办
  13. MySQL简概
  14. 一 Django模型层简介(一)
  15. Java并发-对象共享
  16. 章节十、3-CSS Selector---用CSS Selector - ID定位元素
  17. vue获取路由地址栏url里面的指定参数
  18. npm ERR! Cannot read property &#39;path&#39; of null
  19. ls -l 和du 的区别
  20. 4.ClassLink - 一种新型的VPC 经典网络的连接方式

热门文章

  1. Mono.Android 基础
  2. 关于调用deleteRowsAtIndexPaths withRowAnimation方法出现错误
  3. Android 媒体存储服务(一)
  4. C# js jquery复制textbox内容总结
  5. (转)C#实现MD5加密
  6. Python实现对文件夹内文本文件递归查找
  7. 想一想social VR might just work
  8. c51
  9. UE4 去除不正确的水面倒影以及不完整镜头轮廓
  10. 获取select标签选中状态 的label的值。