Browse Source

明确支持when_all/when_any功能

tags/v2.9.7
tearshark 4 years ago
parent
commit
662fd91a02
3 changed files with 5 additions and 9 deletions
  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 View File

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

+ 0
- 4
librf/src/when.cpp View File

@@ -1,7 +1,5 @@
#include "_awaker.h"
#if _HAS_CXX17 || RESUMEF_USE_BOOST_ANY
#include "when.h"
#include <assert.h>
@@ -42,5 +40,3 @@ namespace resumef
}
}
}
#endif

+ 3
- 1
librf/src/when.h View File

@@ -18,6 +18,7 @@ namespace resumef
#include "_awaker.h"
#include "promise.h"
#include "promise.inl"
#include "awaitable.h"
//纠结过when_any的返回值,是选用index + std::any,还是选用std::variant<>。最终选择了std::any。
@@ -51,9 +52,10 @@ namespace resumef
//如果已经触发了awaker,则返回true
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)
{
(void)dummy_;
return wait_(std::make_shared<when_awaker>(std::forward<callee_t>(awaker)));
}

Loading…
Cancel
Save