瀏覽代碼

明确支持when_all/when_any功能

tags/v2.9.7
tearshark 4 年之前
父節點
當前提交
662fd91a02
共有 3 個文件被更改,包括 5 次插入9 次删除
  1. 2
    4
      librf/librf.h
  2. 0
    4
      librf/src/when.cpp
  3. 3
    1
      librf/src/when.h

+ 2
- 4
librf/librf.h 查看文件

/* /*
*Copyright 2017 lanzhengpeng
*Copyright 2017~2020 lanzhengpeng
* *
*Licensed under the Apache License, Version 2.0 (the "License"); *Licensed under the Apache License, Version 2.0 (the "License");
*you may not use this file except in compliance with the License. *you may not use this file except in compliance with the License.
#include "src/promise.inl" #include "src/promise.inl"
#include "src/state.inl" #include "src/state.inl"
#include "src/sleep.h" #include "src/sleep.h"
#if _HAS_CXX17 || RESUMEF_USE_BOOST_ANY
#include "src/when.h" #include "src/when.h"
#endif

+ 0
- 4
librf/src/when.cpp 查看文件

#include "_awaker.h" #include "_awaker.h"
#if _HAS_CXX17 || RESUMEF_USE_BOOST_ANY
#include "when.h" #include "when.h"
#include <assert.h> #include <assert.h>
} }
} }
} }
#endif

+ 3
- 1
librf/src/when.h 查看文件

#include "_awaker.h" #include "_awaker.h"
#include "promise.h" #include "promise.h"
#include "promise.inl" #include "promise.inl"
#include "awaitable.h"
//纠结过when_any的返回值,是选用index + std::any,还是选用std::variant<>。最终选择了std::any。 //纠结过when_any的返回值,是选用index + std::any,还是选用std::variant<>。最终选择了std::any。
//如果已经触发了awaker,则返回true //如果已经触发了awaker,则返回true
RF_API bool wait_(const when_awaker_ptr & awaker); RF_API bool wait_(const when_awaker_ptr & awaker);
template<class callee_t, class dummy_t = std::enable_if<!std::is_same<std::remove_cv_t<callee_t>, event_awaker_ptr>::value>>
template<class callee_t, class dummy_t = std::enable_if<!std::is_same<std::remove_cv_t<callee_t>, when_awaker_ptr>::value>>
auto wait(callee_t && awaker, dummy_t * dummy_ = nullptr) auto wait(callee_t && awaker, dummy_t * dummy_ = nullptr)
{ {
(void)dummy_;
return wait_(std::make_shared<when_awaker>(std::forward<callee_t>(awaker))); return wait_(std::make_shared<when_awaker>(std::forward<callee_t>(awaker)));
} }

Loading…
取消
儲存